tags:

views:

30

answers:

2
+2  A: 

You need:

#include <string>

Also, your while-loop is wrong - you should not normally use the eof() function as a loop control - use:

  while( fileStream >> tempStr )
   {
     strText += tempStr;
     cout << strText;      // note operator <<
   }

And I just noticed that your cout statement was incorrect too.

anon
Why not use eof()? I've used it in the past with no problems...
graham.reeds
@Graham Consider what happens if the file is empty. eof() only works AFTER you have tried to read something.
anon
Thanks. i was using the wrong operator for cout. It works now. Good point with the eof(). I've made changes to the while statement too.
svenus
@Neil Good point. I guess I've never read an empty file!
graham.reeds
+2  A: 

Add

#include <string>

And change

cout >> strText;

To

cout << strText; 
graham.reeds
thanks. works now.
svenus
There was no need for #include <string>
svenus