c++ - 为什么WHILE循环无法依次读取文件每一行数据?
PHPz
PHPz 2017-04-17 14:36:19
0
1
695


while(!feof(fp)){

fscanf(fp,"%d %s %s %d %d %d\n",&(staff[i].num),staff[i].name,staff[i].sex,&(staff[i].basepay),&(staff[i].extrapay),&(staff[i].day));
*j++;
i++;
}//上图的代码

很简单的代码,就是把txt中每一行的数据依次存入结构体数组中,用for循环有效,但是改成while循环就没用了怎么回事?

PHPz
PHPz

学习是最好的投资!

reply all(1)
Ty80

A low-level error, *j++ needs to be bracketed, it should be (*j)++. Although it has no impact on the problem, it made me mistakenly think that the data was not passed into the structure array. In addition, I ran the search function before and it reported that it did not exist, so I thought the data was not saved.
In addition, the compiler is a bit convulsive. Just turn it off after watching a movie and run it again.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!