我整左3個c program, 第4個要將頭3個program當function用
但copy左頭3個program d野落function度, run o個時出error
唔識debug, 請高人指點..
節錄
int main()
{
void editor();
void typingspeed();
void speed();
void replace();
int choice;
do
{
printf("======Main Menu======\n");
printf("choose a function you want to run");
printf("\n1.simpleEditor\n2.typingSpeed\n3.findAndReplace\n4.Quit\n");
scanf("%d",&choice);
switch(choice)
{case 1:
editor();
break;
case 2:
typingspeed();
break;
case 3:
replace();
break;
case 4:
exit(1);}
system("PAUSE");
return 0;
}
while(choice!=4);
}
void editor()
{
FILE *outFile;
char filename[999];
char f;
char input[9999];
printf("Please enter a filename: ");
gets(filename);
printf("You may start to input your message now!");
printf("\nPlease enter Control-Z when finished.\n\n");
outFile = fopen(filename,"w");
while((f=getchar()) !=26 && f !=EOF)
{
fprintf(outFile,"%c",f);
}
printf("\nThe file %s is created successfully!", filename);
fflush(stdin);
fclose(outFile);
printf("\n\nPlease press ENTER to continue...");
getchar();
}