我如何讀取輸入一個字符串,同時調用另一個函數C.我想這會工作,但我的輸出掛起:同時從文件中讀取一個字符串用C
#define BUFFMT "%255"
#define LINE_LEN 256
#define START_COUNT 1
// filename is declared in the main file elsewhere. I know the file opens since I tried an //old method I use to read one line at time using fgets, but I didn't know how to do one //string at a time. Thanks.
FILE *OpenFile(const char *fileName)
{
FILE *fptr;
if ((fptr = fopen(fileName, "r")) == NULL) {
fprintf(stderr, "Error opening file %s, exiting...", fileName);
exit(EXIT_FAILURE);
}
return fptr;
}
LIST *CreateList(FILE *fp)
{
char buf[LINE_LEN];
while (scanf(BUFFMT"s", buf) != EOF) {
printf("%s: \n", buf);
}
}
你如何在主程序中調用這些函數? – 2011-11-03 01:02:44