/* faruk gologlu * * 106158-9 */ #include #include #include #include #define MAX_LENGTH 201 #define MAX_PATH 10001 /* fopen with file access control. * * #include */ FILE *f_fopen (const char *path, const char *mode) { FILE *fp; if (!(fp = fopen(path,mode))) { fprintf(stderr,"error : in fopen(\"%s\", \"%s\")\n", path, mode); fprintf(stderr,"ERROR %d\n", errno); exit(-1); } return fp; } /* randomize and random functions * * #include and */ void f_randomize() { time_t t; unsigned long seed; time(&t); seed = (unsigned long) t; srand(seed); } /* random(size) : returns 0 .. size-1 */ int f_random(int size) { return ((int) ( (float) size * rand()/(RAND_MAX+1.0))); }