Help with fstream

Pages: 12
Oh, that seems really helpful then. But if it means you don't have to put 'std::' why do most people not bother with it?

Right, so I declared the strings but now it comes up with this:

C:\Users\owner\Documents\Simple RPG game\main.cpp|16|error: cannot convert 'std::string' to 'int' in return|

At least it's only 1 error now haha
Where's your error coming from? The stream function?

Your function should look something like this:
1
2
3
4
5
6
7
8
9
10
11
int streamInt( std::string i )
{
	int convertedInt= 0;

	std::stringstream ss( i );

	if( ss >> convertedInt )
		return convertedInt;
	else
		return 0;
}


And I use std:: because of conflicting naming. This will explain it better:
http://www.parashift.com/c++-faq-lite/coding-standards.html#faq-27.5
Replaced the function with your one. Works fine now. Thank you so much!
No prob. Good luck coding (:
Topic archived. No new replies allowed.
Pages: 12