#include<哪谈stdio.h>
void main() { FILE *fp,*tpchar buffer[256]
if ( fp=fopen("c:\\data\\a.txt","r") ) {
if ( tp=fopen("c:\\data\\b.txt","w+") ) {
while ( !feof(fp) ) {
fgets(buffer,256,fp)
if ( buffer[0]='R' &&buffer[1]='E' &&buffer[2]='C' &&buffer[3]='T' )
sprintf(buffer,"RECT 1.215 1.000 1.000 1.000\n")
fputs(buffer,256,tp)
}
fclose(tp)
} else printf("无法建立b.txt。\巧春n")
fclose(fp)
} else printf("无法打开a.txt读取。\n")
}
其中的条孝缓耐件语句的条件可以修改成需要的条件
#include <森行stdio.h>main()
{char a[100]="0",b[100]
FILE *fp
if((fp=fopen("e:\\1.txt","w+"))==NULL)
{printf("找不到文件")
exit(0)
}
printf("输入字符串:")
scanf("此雹哗%s",a)
fputs(a,fp)
printf("已写入e盘肆拦1.txt\n")
printf("读取e盘1.txt...\n")
fseek(fp,0,0)
fgets(b,100,fp)
printf("成功读入b字符串数组\n")
printf("%s",b)
fclose(fp)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)