-
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.
-
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.
-
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 :)