回 帖 发 新 帖 刷新版面

主题:[原创]求能能读txt文档或能输出txt文档的程序

最近学习标准IO库,发现不懂文件的读写,望高手给几个实例程序,程序能读txt文档,或能输出txt文档。谢谢!

回复列表 (共3个回复)

沙发

任何一本书上都有的

板凳


用有关文件的几个函数就行,
FILE *ch
if((ch=fopen("a.txt","w+"))==NULL)
{
printf("can not openfile\n")
}
……
fclose(ch);
就可以了,

3 楼

    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();

我来回复

您尚未登录,请登录后再回复。点此登录或注册