fstream input

This is a discussion on fstream input within the C++ Programming forums, part of the General Programming Boards category; I named the file ,I wanted opened, a_file just like the example I found so I wouldnt confuse myself. I've ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    12

    Question fstream input

    I named the file ,I wanted opened, a_file just like the example I found so I wouldnt confuse myself. I've tried compiling it and it says that getline is not a member of fstream. (I could have told it that )

    how can I get the following code changed so that I can read a line of text from a file and not get an error.

    a_file.getline(units,8,"/n");


    thanks for any help.

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    155
    I assure you getline() is a member funciton of fstreams as frstreams are derived from ofstreams and ifstreams which in turn are derived from ostreams and istreams meaning fstreams have all the member functions of both output and input streams. The syntax you used should be fine if a_file is an fstream open for reading mode, or if a_file is an ifstream and units is a char array with at least 8 (9?) elements.

    Please post your exact code (or pertinent sections thereof) and the exact error message if you want to pursue this further.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    12
    well thanks but I was talking with someone and I screwed up defining a_file. I cave the command to output to it instead of input. That should take care of my problem

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. input redirection
    By sashaKap in forum C Programming
    Replies: 6
    Last Post: 06-25-2009, 02:59 AM
  2. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 04:42 PM
  3. Structure and Linked List User Input Question
    By kevndale79 in forum C Programming
    Replies: 16
    Last Post: 10-05-2006, 12:09 PM
  4. fstream char array input question
    By mcdms in forum C++ Programming
    Replies: 6
    Last Post: 12-07-2004, 10:40 PM
  5. need help with some input
    By blindleaf in forum C Programming
    Replies: 2
    Last Post: 03-16-2003, 01:50 PM

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