From: "Mr. Veli Suorsa" Sender: vjsuorsa AT Surfeu DOT Fi To: Djgpp AT delorie DOT com Cc: VJSuorsa AT Surfeu DOT Fi Date: Fri, 6 Apr 2001 23:50:17 +0300 Subject: Read with C++ X-Mailer: CWMail Web to Mail Gateway 2.6k, http://netwinsite.com/top_mail.htm Message-id: <3ace2c09.4fbe.0@surfeu.fi> X-User-Info: 193.167.106.194 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Hi! Can You help me to convert this ascii- file reader (tested C program) to Gnu C++ using library? And how do you put these read lines to an array ( lines[MAXLINELEN][ROW] )? --- /* Program read lines from file. (strread.c), Veli Suorsa, 06.04.2001 */ #include #define MAXLINELEN 110 int main( int argc, char *argv[] ) { char filename[30], strline[MAXLINELEN]; int line = 0; FILE *fileptr; // Test if given parameter if ( argc != 2 ) { printf( "\nGive data file name : " ); gets( filename ); } else { // Copy parameter to filename strcpy( filename, argv[1] ); } // Test if can read file if ( ( fileptr = fopen( filename, "r" ) ) == NULL ) { printf( "\nError: File: %s can't read.\n", filename ); exit(0); } // List file printf( "\nFile %s list :\n", filename ); // Read and list, while not end of file while ( !feof( fileptr )) { fgets( strline, MAXLINELEN, fileptr); printf( "%s", strline); // Line counter line++; } // Close file fclose( fileptr ); printf( "\n*** Read: %d rows from file: %s.\n", line, filename ); return 0; } --- Thanks in advance! Veli Suorsa --- "People must believe to the future to be able to live!" ---------------------------------- J.V.Snellman, 1890. Oulu, FINLAND Mailto:VJSuorsa AT Surfeu DOT Fi http://members.surfeu.fi/veli.suorsa/ http://www.surfeu.fi