Why can't I call get line?

I need to use a getline function, however whenever I use one I get an error message. I included <string> and <iostream>. Any help would be appreciated.
If the error message is "Too much cheese in desk drawer", take some cheese out of the drawer. If the error message is something else, you'll have to just tell us so we can help you.
Last edited on
std::getline, perhaps?
It says there is no matching function to call. (That cheese in the drawer was pretty smelly)
Check your arguments? The message may also list the available signatures that you aren't quite matching.

BTW, it helps if you actually paste the error message for us, verbatim.
Last edited on
Sounds like you're giving it the wrong parameters.
Here is the solution to your problem

http://programsplusplus.blogspot.com/p/test-page-1.html
It literally says there is no matching function to call for get line.
You have to give us the line of code or we can't see how you are feeding it which is what you are doing wrong.

I ussually suggest using:
1
2
string myString;
getline(cin, myString)

As per http://cplusplus.com/reference/string/getline/

But there are other ways to use it with characters:
1
2
char myChars[256];
cin.getline(myChars,256);

http://cplusplus.com/reference/iostream/istream/getline/

Really there are 4 forms:
1
2
3
4
istream& getline ( istream& is, string& str, char delim );
istream& getline ( istream& is, string& str );
istream& getline (char* s, streamsize n );
istream& getline (char* s, streamsize n, char delim );
Last edited on
It literally says there is no matching function to call for get line.


Are you feeding it the right parameters?
i think you need using namespace std or std::
Without the line of code in question and the exact error message, we're just suggesting options. With those two, you'd have had the answer literally a minute after your first post :(

In broad terms, you're trying to call a function that your compiler cannot find. This is because it either doesn't exist (wrong parameters) or the compiler doesn't know it exists (missing includes) or you've directed it to look in the wrong place (bad namespaceing).
or (based on how you wrote it in the title) you are doing get [space] line instead of getline
Topic archived. No new replies allowed.