Possible Duplicate:
Reading through file using ifstream
I’m trying to find a way to read something from a file, put it into a string and then output it onto the screen. If you know how to do this can you give an example?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This code will read the entire first line of the file.
If you want to read the file line by line you could do something like this:
Not sure what you mean by ‘need to read something‘, but you could use a stringstream for conversions.