C/C++の宿題やらせてください。7代目。
レス数が950を超えています。1000を超えると書き込みができなくなります。
0985r
NGNG#include <stdio.h>
#include <stdlib.h>
#define CELL_SIZE 100
typedef struct cell {
char data[ CELL_SIZE + 1 ];
struct cell* next;
}cell_t;
cell_t* CreateCell() { return (cell_t*)calloc( 1, sizeof( cell_t ) ); }
void Cell_Display( const cell_t* cell ) {
while( cell != 0 ) {
fputs( cell -> data, stdout );
cell = cell -> next;
}
}
void Cell_Clear( cell_t* cell ) {
cell_t* target;
while( cell != 0 ) {
cell = ( target = cell ) -> next;
free( target );
}
}
int main(int argc, const char** argv) {
cell_t *head, *tail;
FILE* fp = 1 < argc ? fopen( argv[1], "r" ) : stdin;
tail = head = CreateCell();
while( !feof( fp ) )
fgets( ( tail = tail -> next = CreateCell() ) -> data, CELL_SIZE, fp );
Cell_Display( head );
Cell_Clear( head );
}
レス数が950を超えています。1000を超えると書き込みができなくなります。