C Program問題[function]-急-

2008-12-12 10:31 am
我整左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();
}

回答 (4)

2008-12-12 3:10 pm
✔ 最佳答案
我淨係見到一個function, 好多時o的error message係因為其他地方寫錯o野攪到佢唔識parse

你又冇講有咩error message, 點幫你debug

2010-04-25 5:53 am
要return d野
唔好用void function_name()
2008-12-12 8:50 pm
驟眼睇,個program 的 syntax錯得好緊要。(http://feelaa.com/download/c.txt)

首先,c來說,function之中是不能有function的。例如,你咁寫一定錯:

void typingspeed()
{
void speed() {
.....
.....

請把 speed() function 放到 typingspeed() 之外。

其他果d我無咁好心機同你睇,執生吧^^
2008-12-12 4:51 pm
If you add at the beginning,
#include <stdio.h>
and define your functions replace() and typingspeed() somewhere
there will be no compilation errors.

If you have execution errors, it depends on how you write the two missing functions. You need to post the complete code and the error messages (as mentioned by 阿一 upstairs).


收錄日期: 2021-04-13 16:18:19
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20081212000051KK00153

檢視 Wayback Machine 備份