Hi.
The objective os to open a file and print 55 lines of content at a time. Since I am still learning 'C', my code (thus far) may appear slightly neophytic ;)
#include <stdio.h>
#include <stdlib.h>
#define SIZE 1000
void pause( void );
int main( void ) {
FILE* fp;
int count, line = 0;
char buf[SIZE];
if( ( fp = fopen( "data.txt", "r" ) ) == NULL ) {
fprintf( stderr, "Error opening file.\n" );
exit( 1 );
}
fgets( buf, SIZE, fp );
fclose( fp );
for( count = 0; count != EOF; count++, line++ ) {
while( line % 55 != 0 )
printf( "%c\n", buf[count] );
pause();
}
return 0;
}
void pause( void ) {
char input[5];
printf( "Press return when ready..." );
gets( input );
}
Thanks.