fp=fopen("c:\\test.txt","rt")
修改后关闭文件
fclose(fp)
再打开文件写
fp=fopen("c:\\test.txt","wt")
首先打开文件fp=fopen("filename","r")
if(!fp)
{printf("Can't
open
file!")
eixt(1)}
char
a[10]/*存放字符串*/
int
t/*存放数字*/
if(!fscanf(fp,"%s",a))/*fscanf()在读取失败时返回*/
printf("read
fail!\n")
else
printf("%s",a)
fscanf(fp,"%s",a)
if(!strcmp(a,"program"))
{
printf("programs
are:\n")
while(!feof(fp))/*没有到文件结尾一直读取输出*/
{fscanf(fp,"%d",t)printf("%d",t)}
主干过程就是这样,你再完善一下!
希望能够帮到你!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)