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.

29th Dec 2019, 2:49 PM
Chetan Satpute
Chetan Satpute - avatar
1 Respuesta
+ 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().
30th Dec 2019, 6:30 PM
Mark