繁体   English   中英

读取文件后打印输出时没有空格

[英]no spaces while printing the output after reading the file

我正在尝试打印要输出的文件内容,但是输出缺少文件中的空格。 我也尝试过使用infile >> noskipws >> ch; 但它仅显示文件中的第一个单词。

int process_infile(int shift)
{   
    char c[1000];
    ifstream ifile;
    ifile.open("D:\\example.txt") ;
    if(!ifile)
    {
        //cout<<"Error in opening file..!!";
        error();
        //getch();
        exit(1);
    }
    cout<<"Data in file = ";
    while(ifile.eof()==0)
    {
        ifile >> c;
        cout << c;
        //encodeCaesarCipher(c,shift);
    }       
    ifile.close();
    getch();
    return 1;
}

尝试

while(ifile.eof()==0)
{
  string line;
  getline(ifile,line);
  cout << line;
        //encodeCaesarCipher(c,shift);
}   

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM