我想从文本文件中读取非数字字,它可以用逗号,点,冒号或引号或这样的一些组合来分隔“。到目前为止,在读非数字的话 正确,但使用的fscanf离开delimiters.Am我()吧?使用fscanf()的格式化输入
int ReadWords(FILE* fp, char *words[])
{
int i=0;
char temp[50],tmp[50]; // assuming the words cannot be too long
while (fscanf(fp,"%s%*[,.\":]",temp)==1) //ignore punctuation
{
if (isNumeric(temp))
continue;
printf("%s\n",temp);
words[i] = strdup(temp);
i++;
}
fclose(fp);
// The result of this function is the number of words in the file
return i;
}
我越来越像输出
emergency,"
"an
unknown
car
entered,
我需要一个像
emergency
an
unknown
car
entered
请更新您的问题标题,以便更具体地了解您要区分的输入类型。 – 2014-10-17 06:59:28