How do I read spaces in a text file?

I am attempting to read in a text file and loop through each character of the file as I will be modifying each character as it's read in. I noticed that all the spaces from the file are not being read. How can I keep the spaces so that I can modify them?

1
2
3
4
5
while (inFile)
	{
		inFile >> fileChar;
		cout << fileChar;
	}


Any help is appreciated. Thanks,
Return 0;
Use getline() function, it reads the entire line spaces and all.
You can also just turn off the skip whitespace flag:
1
2
3
4
5
6
inFile >> noskipws;
while (inFile)
	{
		inFile >> fileChar;
		cout << fileChar;
	}

Keep in mind that >> is for formatted input, though in this case you shouldn't have any problem.

Hope this helps.
Topic archived. No new replies allowed.