Connecting Tech Pros Worldwide Forums | Help | Site Map

trouble with char* and strings

Newbie
 
Join Date: Dec 2008
Posts: 1
#1: Dec 20 '08
hi, i'm trying to read a text file and grab names from each line. the text file looks like this

Alice
Bob
Charlie
etc

I'm trying to use while(getline(cin,Names))
I then want to put "Alice" into "Names", so that I can use it further on. I'ts coming up with this error:

33 C:\Users\mehth\Desktop\Names.cpp no matching function for call to `getline(std::istream&, char*&)'

JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#2: Dec 20 '08

re: trouble with char* and strings


Where is that function 'getline' defined or at least declared? That's what your compiler is whining about: it can't find such a definition or declaration. Check your manual.

kind regards,

Jos
Moderator
 
Join Date: Mar 2006
Posts: 1,103
#3: Dec 22 '08

re: trouble with char* and strings


I believe the syntax would be:

while(cin.getline (Names,256))

unless you have declared a getline function somewhere else in your program code.
getline - C++ Reference
Reply