use of getline()

This is a discussion on use of getline() within the C++ Programming forums, part of the General Programming Boards category; Hello, this is my first time posting; so please excuse me for any ettiquettes that I may break. On to ...

  1. #1
    dat
    dat is offline
    Registered User
    Join Date
    Nov 2001
    Posts
    28

    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.


    Best Regards,

    Nick

  2. #2
    Unregistered
    Guest
    I think getline() is defined in iostream.h...

    Have you #include <iostream.h> at the top of your code?

  3. #3
    dat
    dat is offline
    Registered User
    Join Date
    Nov 2001
    Posts
    28
    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

    Regards,

    Nick

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getline() don't want to work anymore...
    By mikahell in forum C++ Programming
    Replies: 7
    Last Post: 07-31-2006, 10:50 AM
  2. getline problem
    By Bitphire in forum C++ Programming
    Replies: 5
    Last Post: 10-18-2004, 04:42 PM
  3. getline help
    By ProjectsProject in forum C++ Programming
    Replies: 3
    Last Post: 06-14-2004, 11:12 AM
  4. getline not working right
    By talz13 in forum C++ Programming
    Replies: 11
    Last Post: 12-10-2003, 10:46 PM
  5. getline with string class in Borland C++
    By johnnyd in forum C++ Programming
    Replies: 6
    Last Post: 03-08-2003, 01:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21