![](/img/trans.png)
[英]reading from a text file and printing every number right away gives different output than printing after reading all the file
[英]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.