Problem with ifstream::getline

Discussion in 'C++' started by tinks, Nov 8, 2005.

  1. tinks

    tinks Guest

    I am getting a linking error when I do something like this:

    ifstream dataFile;
    dataFile.open(dataFileName_, ios::in);
    while(dataFile)
    {
    dataFile.getline(buffer, MAX_DATA_FILE_LINE_LEN); // This line
    creates linking issue on solaris
    }

    The getline call leads to a linking error on sunwspro/6.2 and works
    fine on linux.

    __1cDstdNbasic_istream4Ccn0ALchar_traits4Cc___Hgetline6Mpclc_r1 not
    found.

    Any help is appreciated.
    tinks, Nov 8, 2005
    #1
    1. Advertising

  2. tinks

    BobR Guest

    tinks wrote in message
    <>...
    >I am getting a linking error when I do something like this:
    >
    >ifstream dataFile;
    >dataFile.open(dataFileName_, ios::in);
    > while(dataFile)
    > {
    > dataFile.getline(buffer, MAX_DATA_FILE_LINE_LEN); // This line
    >creates linking issue on solaris
    > }
    >
    >The getline call leads to a linking error on sunwspro/6.2 and works
    >fine on linux.
    >
    >__1cDstdNbasic_istream4Ccn0ALchar_traits4Cc___Hgetline6Mpclc_r1 not
    >found.
    >Any help is appreciated.


    ?
    'buffer' is not declared/defined. size==Big_Enough.
    MAX_DATA_FILE_LINE_LEN is not declared/defined.
    std::basic_istream::getline(char*, int) is not defined.
    ?

    #include <iostream>
    #include <ostream>
    #include <string>
    #include <vector>
    #include <fstream>

    int main(){
    std::vector<std::string> vec1;
    std::string buffer;
    std::string fName( dataFileName_ );
    std::ifstream infile( fName.c_str() );
    if( not infile){ return EXIT_FAILURE;}
    while( getline( infile, buffer ) ){
    vec1.push_back ( buffer );
    } // while()
    for( size_t a(0); a < vec1.size(); ++a){
    std::cout<<vec1.at(a)<<std::endl;
    } // for(a)
    return 0;
    } // main() end

    and it looks like some newer implementations may need:
    std::getline()
    std::size_t

    Being a smart-ass is an art, being an idiot is natural! (or was that the
    other way around?)<G>
    --
    Bob R
    POVrookie
    BobR, Nov 9, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John
    Replies:
    10
    Views:
    10,020
    Buster Copley
    Jul 14, 2003
  2. Joe
    Replies:
    4
    Views:
    7,735
    Chris Theis
    Jan 22, 2004
  3. Jim Phelps
    Replies:
    1
    Views:
    1,710
    Karl Heinz Buchegger
    Jan 21, 2004
  4. Christopher Benson-Manica

    ifstream/getline

    Christopher Benson-Manica, Apr 1, 2004, in forum: C++
    Replies:
    15
    Views:
    28,487
    Leor Zolman
    Apr 1, 2004
  5. Assertor
    Replies:
    2
    Views:
    2,561
    Assertor
    Feb 26, 2006
Loading...

Share This Page