主题:[原创]求能能读txt文档或能输出txt文档的程序
haodongdong
[专家分:30] 发布于 2010-04-06 18:40:00
最近学习标准IO库,发现不懂文件的读写,望高手给几个实例程序,程序能读txt文档,或能输出txt文档。谢谢!
回复列表 (共3个回复)
沙发
liudan319 [专家分:3780] 发布于 2010-04-06 22:11:00
任何一本书上都有的
板凳
hongqigong [专家分:10] 发布于 2010-04-06 22:38:00
用有关文件的几个函数就行,
FILE *ch
if((ch=fopen("a.txt","w+"))==NULL)
{
printf("can not openfile\n")
}
……
fclose(ch);
就可以了,
3 楼
honemay [专家分:60] 发布于 2010-04-08 16:59:00
char xmlName[256];
sprintf(xmlName, "%s/%s", "./log", "xml.log");
ofstream of;
of.open(xmlName, ios::app |ios::out);
char* str = "hello你好!";
of.write(str, strlen(str));
of.close();
我来回复