首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

一个相当简单地的程序,为什么会出错?该怎么解决

2012-03-01 
一个相当简单地的程序,为什么会出错?#includeiostream#includestring#includefstreamusingnamespace

一个相当简单地的程序,为什么会出错?
#include   <iostream>
#include   <string>
#include   <fstream>
using   namespace   std;


int   main()
{
    ofstream   outfile( "out_file.txt ");
    ifstream   infile( "in_file.txt ");
    if(!infile)
    {   cerr < < "error:unable   to   open   an   input   file " < <endl;
            return   -1;
    }
    if(!outfile)
    {     cerr < < "error:unable   to   open   an   output   file " < <endl;
            return   -2;
    }
    string   str;
    while(infile> > str)
    {
        outfile < <str < < ' ';
    }
    return   0;
}

提示错误:
test.cpp(22)   :   error   C2137:   empty   character   constant

我已经建立了一个out_put.txt和一个in_put.txt(内含一段文本)

[解决办法]
' '
改成 ' '是一个空格吧,不是没有东西~
[解决办法]
outfile < <str < < ' ';

热点排行