afile help

closed account (STR9GNh0)
if

1
2
3
4
5
6
7
8
9

	while (!afile.eof())
	{ 
		ch = afile.get(); 
		afile << ch;
	}




if my afile last letter is an empty space...

how can i omit the space to be displayed in the output?

i have to use character instead of a string - string i know can do '\0' though

thanks
Last edited on
If you use the extraction operator ">>" to read from the file then it will not grab the white space. You'll have to add a space in between words in your code yourself but it should do what you want.

Right now your code doesn't have any effect on the file. Are you just experimenting?
closed account (STR9GNh0)
Yep.

Erm well..

Think i have explained it wrongly.

Currently my afile have 3 line of numbers and the 4th line and onwards is empty..

Is there a way to check if anything after the 3rd line of text it w not print the 4th line since it should be empty?

Somehow my afile the 4th line is empty but the compiler keeps reading in as well... As a space.
Last edited on
closed account (STR9GNh0)
Any experts?
Topic archived. No new replies allowed.