我有一個代碼,我想檢查文件中的行數。該文件有6行。我嘗試與新行'/ n'比較,但結果不好。這是代碼。請幫助:)用新行C比較字符
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE*code;
int NumbRow = 0;
char c;
code = fopen("SMS.txt", "r");
if(code==NULL)
{
printf("I cant read from file");
return;
}
again:
while ((c=fgetc(code)) !=EOF)
{
if (c=='/n')
{
NumRow ++ ;
}
if (c!='/n')
{
goto again;
}
}
printf ("Number of rows is : %d", NumRow);
return 0;
}
嗯。 「但結果不好」不是一個非常準確的問題陳述。 –
goto是什麼? – pinkfloydx33