簡體   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