Why can't I call get line?

Jan 19, 2012 at 9:37pm
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.
Jan 19, 2012 at 9:38pm
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 Jan 19, 2012 at 9:39pm
Jan 19, 2012 at 9:40pm
std::getline, perhaps?
Jan 20, 2012 at 1:21am
It says there is no matching function to call. (That cheese in the drawer was pretty smelly)
Jan 20, 2012 at 2:07pm
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 Jan 20, 2012 at 2:08pm
Jan 20, 2012 at 2:17pm
Sounds like you're giving it the wrong parameters.
Jan 20, 2012 at 3:22pm
Here is the solution to your problem

http://programsplusplus.blogspot.com/p/test-page-1.html
Jan 20, 2012 at 7:09pm
It literally says there is no matching function to call for get line.
Jan 20, 2012 at 7:32pm
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 Jan 20, 2012 at 7:39pm
Jan 20, 2012 at 8:35pm
It literally says there is no matching function to call for get line.


Are you feeding it the right parameters?
Jan 20, 2012 at 9:04pm
i think you need using namespace std or std::
Jan 20, 2012 at 9:08pm
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).
Jan 20, 2012 at 10:31pm
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.