void main()
{
int count=0,temp
FILE * fp
fp = fopen("test1.txt "," r ");
而(!Feof(FP))//這個函數的feof決定了文件指針是否到達文件的末尾。
{
fscanf(fp," %d\n ",& amptemp);//fscanf如何使用這個函數可以在百科名片中了解。
printf("%d\n ",temp);
count++;
}
fclose(FP);
Printf("***有%d個數據",count);
}
修改程序,向文本中輸入數據,並從文本中計算輸出數據的數量
# include & ltstdio.h & gt
void main()
{
int count=0,temp
FILE * fp
fp = fopen("test1.txt "," w ");
while(scanf("%d ",& amp溫度))
{
fprintf(fp," %d\n ",temp);
}
fclose(FP);
fp =fopen("test1.txt "," r ");
而(!feof(fp))
{
fscanf(fp," %d\n ",& amptemp);
printf("%d\n ",temp);
count++;
}
fclose(FP);
Printf("***有%d個數據",count);
}