怎么将c 输出内容存放到txt中?

[复制链接]
查看11 | 回复4 | 2011-10-16 01:43:01 | 显示全部楼层 |阅读模式
是c代码不是c。#includeiostreamusingnamespacestd;intmain(){inta,b,c;a=1;b=2;c=ab;cout\"两数之和为:\"cendl;//我想把这个输出的“c”输出到桌面的“GM.txt”中,使txt中显示如图,怎么修改代码?return0;}加的代码属于c哪个章节学习的。
回复

使用道具 举报

千问 | 2011-10-16 01:43:01 | 显示全部楼层
增加头文件:#includefstream在主函数一开始增加:ofstreamcout(\"GM.txt\",ios::out);这样就可以了。注意把“GM.txt\"替换成桌面路径。
回复

使用道具 举报

千问 | 2011-10-16 01:43:01 | 显示全部楼层
#includestdio.hintmain(){FILE*f=fopen(\"GM.txt\",w);//fopen的详细介绍参见http://baike.baidu.com/view/656681.htminta,b,c;a=1;b=2;c=ab;fprintf(\"%d\",c);return0;}
回复

使用道具 举报

千问 | 2011-10-16 01:43:01 | 显示全部楼层
#includefstreamintmain(){std::ofstreamofile3;}
回复

使用道具 举报

千问 | 2011-10-16 01:43:01 | 显示全部楼层
#includefstream#includeiostreamusingnamespacestd;intmain(){ofstreamfile(\"e://notpad.txt\");chara[10];cina;filea;}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行