Updated to be fully C99 compatible
This commit is contained in:
parent
b0240c4911
commit
9a8665ed26
2 changed files with 10 additions and 4 deletions
12
connect4.c
12
connect4.c
|
|
@ -143,8 +143,14 @@ int main(
|
|||
playboard.rows = (rowsint_t)atoi(optarg);
|
||||
break;
|
||||
case 'o':
|
||||
filename = strdup(optarg);
|
||||
outputfile = fopen( filename, "w" );
|
||||
// filename = strdup(optarg);
|
||||
filename = calloc( strlen( optarg ) + 1, sizeof(char) );
|
||||
if( filename != NULL ){
|
||||
strcpy( filename, optarg );
|
||||
outputfile = fopen( filename, "w" );
|
||||
}else{
|
||||
fprintf( stderr, "ERR: COULD NOT ALLOCATE FILENAME\n" );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -185,7 +191,7 @@ int main(
|
|||
playboard.height = calloc( playboard.columns, sizeof(rowsint_t) );
|
||||
playboard.column = calloc( playboard.columns, sizeof(column_t) );
|
||||
if( playboard.height == NULL || playboard.column == NULL ){
|
||||
fprintf( stderr, "ERROR: COULD NOT ALLOCATE BOARD" );
|
||||
fprintf( stderr, "ERROR: COULD NOT ALLOCATE BOARD\n" );
|
||||
return 1;
|
||||
}
|
||||
// Initialize wins struct if used
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue