hi!
as it appears u are going to need this line later in the programme for some processing [whatever] you can just read the line in a separate buffer - some string [char array] like:
Code:
char buffer[129];
fin.getline(buffer, 129, '/n'); /* assumes fin is an ifstream object already connected to a file */
generally speaking, the prototype of getline is:
istream& getline (char *s, streamsize n, char delim );
getline extracts characters from the input stream storing them into succesive locations in the buffer pointed to by char *s - a char array for instance. it will read n-1 characters (in the above example 128 characters - the maximum number of characters per line as far as i know - very unlikely to be that much anyway). the
char delim is the character up to which getline is going to read [that is if it does not read n-1 characters first]. in other words, if the delimiter character is encountered before n-1 chars have been read the reading is stopped and the delimiter is
extracted from the stream, but
not stored.
specifying the delimiter is optional. if none is specified the '/n' char is assumed, eg the end of line.
reading is also stopped of the eof (end-of-file) character is found.
so you can just write:
Code:
fin.getline(buffer, 129);
ah, also, getline autmatically appends the null char '/0' to the buffer.
ok. hope that helps, and doesnt just confuse. i dont think im very good at explaining hehe. too many words
if this doesnt work, elaborate on the problem, just as Kapadia says. i think her method might be much better, but it all depends on the specs of ur case.
Avendeval Sedai
yavoor@yahoo.com