Skywise wrote:
>
> > You cannot use a string variable with getline like that.
> > For using strings there is a standalone getline function, which
> > does what you want.
> >
> > getline( fin, Temp );
> >
>
> Ok, I did that. Then I got this error:
>
> error C2065: 'getline' : undeclared identifier
>
> I figured maybe I needed to write it like this:
>
> std::getline( fin, Temp);
>
> But that didn't work either, and I get these errors:
First of all we need to confirm something.
The string class mentioned in your previous post, how did
you get it? Did you
#include <string>
I am worried because the previous error message tells us that
there is no conversion from const char* to char*. Which would
only be possible if there is a way for a string object to be
implicitely converted to a const char*, which there is none.
So: Are you using the std::string class?
The function getline is available when you
#include <string>
which again makes me think that you are not using std::string
Try this program. It should compile without a problem.
#include <string>
#include <iostream>
using namespace std;
int main()
{
string input;
getline( cin, input );
cout << "You entered " << input << endl;
}
--
Karl Heinz Buchegger