getline error

This is a discussion on getline error within the C++ Programming forums, part of the General Programming Boards category; I get the following error when I try to use getline to read data in from a text file: error ...

  1. #1
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065

    getline error

    I get the following error when I try to use getline to read data in from a text file:

    error C2664: 'class istream &__thiscall istream::getline(char *,int,char)' : cannot convert parameter 3 from 'char [2]' to 'char'

    Here's the offending code:
    Code:
    char cIn[200];
    char cFile[9]="test.txt";
    ifstream bFile(cFile);
    while(!bFile.eof())
        {
        bFile.getline(cIn,200,"\n");
           MessageBox(hwnd,cIn,"Debug",NULL);
        }
    I'm using MSVC++ 6.0.

  2. #2
    Unregistered
    Guest

    Re: getline error

    Try this instead:

    Code:
    char cIn[200];
    char cFile[9]="test.txt";
    ifstream bFile(cFile);
    while(!bFile.eof())
        {
        bFile.getline(cIn,200,'\n');
           MessageBox(hwnd,cIn,"Debug",NULL);
        }

  3. #3
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065

    THANKS!!

    It's always the simplest things we (or at least I) miss!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 03:09 AM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12:17 AM
  5. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM

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