*) how to use nanosleep #define TEN_MILLIS_IN_NANOS 10000000 struct timespec t; int seed=0; t.tv_sec = 0; t.tv_nsec = rand_r(&seed)%(TEN_MILLIS_IN_NANOS+1); nanosleep(&t, NULL); *) how to read/write a char and offset from/to a file if (!(file_in = fopen(infile, "r"))) { error("could not open input file for reading"); } ... result.offset = ftell(file_in); /* get position of byte in file */ result.byte = fgetc(file_in); /* read byte from file */ ... fclose(infile) -------------------------------------------------------- if (!(file_out = fopen(outfile, "w"))) { error("could not open output file for writing"); } ... if (fseek(file_out, d.offset, SEEK_SET) == -1) { fprintf(stderr, "error setting output file position to %u\n", (unsigned int) d.offset); exit(-1); } if (fputc(d.byte, file_out) == EOF) { fprintf(stderr, "error writing byte %d to output file\n", d.byte); exit(-1); } ... fclose(infile) *) When does the program finish?