use of getline()
Hello, this is my first time posting; so please excuse me for any ettiquettes that I may break. On to the purpose of this post.
I'm writting a program in C++ to scan a text file and figure out how many characters, words, and lines are in the file. The functions that will perform the task is called "readFile( string s )" which takes a argument of a string which is the file to be scanned. Now on to my problem. I'm using the method/function getline() with these arguments:
getline( inputFile, s );
where inputFile is connected to a ifstream and s is a temporary string to be manipulated.
But when I try to compile I get the error:
d:\cpp\fstats\fs.cpp(46) : error C2065: 'getline' : undeclared identifier
Error executing cl.exe.
I'm using MSVS 6.0
Thanks for any help.
I think getline() is defined in iostream.h...
Have you #include <iostream.h> at the top of your code?
Never mind, I figured it out. Microsoft has a error in MSVS 6.0 that if you overload the << and >> and try to use namespace std you get a weird error. So you have to put std:: before each variable that or word that belongs to the std namespace, which include getline(). Thanks anyways