I have made a text editor in C. When I'm changing the extension of that file from .c to .sh and compiling the file in the terminal, some error is shown, like for the global variables an external error is shown, and for the functions I've declared errors are shown there also. This is my code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int i,j,ec,fg,ec2;
char fn[20],e,c,d;
FILE *fp1,*fp2,*fp;
void Create();
void Append();
void Delete();
void Display();
int main()
{
do {
printf("\n\t\t***** TEXT EDITOR *****");
printf("\n\n\tMENU:\n\t..\n ");
printf("\n\t1.CREATE\n\t2.DISPLAY\n\t3.APPEND\n\t4.DELETE\n\t5.EXIT\n");
printf("\n\tEnter your choice: ");
scanf("%d",&ec);
switch(ec)
{
case 1:
Create();
break;
case 2:
Display();
break;
case 3:
Append();
break;
case 4:
Delete();
break;
case 5:
exit(1);
}
}while(1);
}
void Create()
{
fp1=fopen("temp.txt","w");
printf("\n\tEnter the text and press '.' to save\n\n\t");
while(1)
{
c=getchar();
fputc(c,fp1);
if(c == '.')
{
fclose(fp1);
printf("\n\tEnter then new filename: ");
scanf("%s",fn);
fp1=fopen("temp.txt","r");
fp2=fopen(fn,"w");
while(!feof(fp1))
{
c=getc(fp1);
putc(c,fp2);
}
fclose(fp2);
break;
}
}
}
void Display()
{
printf("\n\tEnter the file name: ");
scanf("%s",fn);
fp1=fopen(fn,"r");
if(fp1==NULL)
{
printf("\n\tFile not found!");
goto end1;
}
while(!feof(fp1))
{
c=getc(fp1);
printf("%c",c);
}
end1:
fclose(fp1);
printf("\n\n\tPress any key to continue..");
}
void Delete()
{
printf("\n\tEnter the file name: ");
scanf("%s",fn);
fp1=fopen(fn,"r");
if(fp1==NULL)
{
printf("\n\tFile not found!");
goto end2;
}
fclose(fp1);
if(remove(fn)==0)
{
printf("\n\n\tFile has been deleted successfully!");
goto end2;
}
else
printf("\n\tError!\n");
end2: printf("\n\n\tPress any key to continue..");
getchar();
}
void Append()
{
printf("\n\tEnter the file name: ");
scanf("%s",fn);
fp1=fopen(fn,"r");
if(fp1==NULL)
{
printf("\n\tFile not found!");
goto end3;
}
while(!feof(fp1))
{
c=getc(fp1);
printf("%c",c);
}
fclose(fp1);
printf("\n\tType the text and press 'Ctrl+s' to append.\n");
fp1=fopen(fn,"a");
while(1)
{
c=getchar();
if(c==19)
goto end3;
if(c==13)
{
d='\n';
fputc(d,fp1);
}
else
{
fputc(c,fp1);
}
}
end3: fclose(fp1);
}

Csyntax is not the same that the shell syntax. You can't just change the extension. It wont work. – Lucio Sep 2 '12 at 22:00