Reply-To: "Jorge Ivan Meza Martinez" From: "Jorge Ivan Meza Martinez" To: Subject: Reading Lines from .txt files Date: Wed, 15 Jul 1998 14:28:30 -0500 Message-ID: <01bdb026$bfd69980$LocalHost@default> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Precedence: bulk Hello to everyone, I don't know if my question fits here but I hope, I need to read lines from an ascii file, I use something like this: #include #include char linea[70]; ifstream archivo_entrada ( filename ); if ( archivo_entrada.fail () ) { cerr << "fallo en archivo_entrada " << filename << endl; return ( false ); } while ( !archivo_entrada.eof () ) { archivo_entrada.getline ( linea, sizeof ( linea ) -1 ); /** asegura que la cadena tenga fin */ linea [76] = '\0'; cout << linea << endl; } archivo_entrada.close (); I open a ifstream and read lines with getline method but the problem is the length of the line, getline reads a const number of bytes, in this case (70)-1; but what if I don't know how many bytes I want to read, worse than that, if the line has more that (70)-1 the program dies. How do you do things like this ? How is the best "DJGPP way" ? I prefer C++ but C is useful to me too. thanks to all. jorge ivan meza martinez http://members.xoom.com/THP jimeza AT usa DOT net