0
Error in reading a file?
I want to clone a text file (ie. to make a new file with all the text in the same format as in the original file) using an ifstream read the file one character at a time, but it skipped all the blank spaces and new line. how can i make it read new line character and blank spaces.
1 Resposta
+ 1
Hi Chetan-Satpute
Try something like:
char ch;
fstream fin("file", fstream::in);
while (fin >> noskipws >> ch)
{
cout << ch;
//Or write ch to a file
}
The key here is to unset the flag skipws.
I think you could do the same easily using the function get().