标题:文件读写问题请教
只看楼主
X1AO
Rank: 3Rank: 3
来 自:北京邮电大学
等 级:论坛游侠
威 望:1
帖 子:52
专家分:123
注 册:2013-3-6
得分:0 
程序代码:
#include<stdio.h>
void main ()
{
FILE  *infile, *outfile;
int x, on, off;
char credit[30], name[30];

printf("\nMy SID is 059353128");
infile=fopen("tobill.txt", "r");
outfile=fopen("record.txt", "w");
for (x=1; x<28; x++)
{
   fscanf(infile, "%[^:]:%[^:]:%d:%d", credit, name, &on, &off);
   getc(infile);
   
}
fprintf(outfile, "Record %d is : %s %s %d %d\n", x, credit, name, on, off);
fclose(infile);
fclose(outfile);
}


把你上面的代码改了一下,亲测可以了。

不要问我下课干什么,我陪瓜哥上厕所。
2013-03-26 08:53
X1AO
Rank: 3Rank: 3
来 自:北京邮电大学
等 级:论坛游侠
威 望:1
帖 子:52
专家分:123
注 册:2013-3-6
得分:0 
record.rar (453 Bytes)
    tobill
求结贴给分,一分也是分啊

[ 本帖最后由 X1AO 于 2013-3-26 15:20 编辑 ]

不要问我下课干什么,我陪瓜哥上厕所。
2013-03-26 08:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-401815-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.917718 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved