reading strings from a file with spaces

HI
I need to write a program that reads a paragraph from a file (i dont know its length) and i need to read it with spaces

i thought of using getline() function but there were problems:
1) how to detect End Of File
2) how to use getline while reading from file

and thought of reading one character at a time but it didnt read spaces

thanks, coder1
Quick and dirty…


1
2
3
4
5
6
7
8
9
10
11
12
std::string line, all;

while (fin.good())
{
	getline(fin, line);
	
	/* Manipulate `line' here... */
	
	all += line;
}

fin.close();
Last edited on
closed account (Dy7SLyTq)
1
2
3
4
5
6
7
string line;
ifstream file("whatev.txt");

while(getline(file, line))
{
	//code
}
Its not working blakek
Its not working DTScode
Last edited on
no im so sorry it is working there was a mistake by me.


so sorry
Topic archived. No new replies allowed.