24小时热门版块排行榜    

查看: 298  |  回复: 1

学化学的笨蛋

金虫 (小有名气)

[求助] 为啥这个输出的结果是0呢?已有1人参与

CODE:
#include<iostream>
#include<fstream>
using namespace std;
int main(void)
{
        ofstream fout("text.txt");
        if(!fout)
        {
                cout<<"不能打开输出文件。"<<endl;
                return 1;
        }
        fout<<"Hello World!"<<endl;
        fout<<6<<endl;
        fout<<hex<<10<<endl;
        fout.close();
        ifstream fin("text.txt");
        if(!fin)
        {
                cout<<"不能打开输入文件。"<<endl;
                return 1;
         }
         int i;
         char ch;
         char c[20];
         fin>>c;
         fin>>i;
         fin>>ch;
         cout<<c<<endl;
         cout<<i<<endl;
         cout<<ch<<endl;
         fin.close();
         return 0;
}

输出结果:
Hello World!
0----------------------------------这里应该是6啊
a

[ Last edited by jjdg on 2015-4-6 at 11:42 ]
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

天下雨了吗?

铁虫 (初入文坛)

【答案】应助回帖

相关版块跳转 我要订阅楼主 学化学的笨蛋 的主题更新
信息提示
请填处理意见