contest file now working
This commit is contained in:
parent
fede23cba7
commit
6dcb9d356f
1 changed files with 11 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "utictactoe.h"
|
||||
|
||||
#define OPTIONAL_ARGUMENT_IS_PRESENT \
|
||||
|
@ -42,7 +43,7 @@ int main(int argc, char* argv[]) {
|
|||
int cross_ai, round_ai = 0;
|
||||
int inception_level = 0;
|
||||
bool contest = false;
|
||||
|
||||
char * contest_file;
|
||||
static struct option long_opts[] =
|
||||
{
|
||||
{"inception-level", optional_argument, 0, 'i'},
|
||||
|
@ -103,7 +104,15 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
case 'c':
|
||||
if ( OPTIONAL_ARGUMENT_IS_PRESENT ) {
|
||||
fprintf(stderr, "Error: contest option doesn't support arguments\n");
|
||||
if ( access(optarg, R_OK | W_OK) != -1) {
|
||||
printf("Contest file valid\n");
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Can't access to file %s\n", optarg);
|
||||
} exit (EXIT_FAILURE);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Error: contest need a file\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
contest = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue