The two loops would be identical except the first wouldn't save the line and the second would:
Code:int n; char buf[81]; char (*lines)[81]; /* fopen fin and such */ n = 0; while ( fgets ( buf, sizeof buf, fin ) != NULL ) { n++; } lines = malloc ( n * sizeof *lines ); rewind ( fin ); n = 0; while ( fgets ( buf, sizeof buf, fin ) != NULL ) { strcpy ( lines[n++], buf ); }