int main() { int fd; char s[50]; time_t t; int i, j, n = 1, maxprime = 3; int max = 100000; /*** time stamp1 here ***/ t = time(NULL); printf("Start time: %s", ctime(&t)); fd = open("file1", O_CREAT | O_TRUNC | O_WRONLY, 0664); while (1) { printf(" "); fgets(s, 50, stdin); // get string if (s[0] == '\n') break; /*** Big processing here ***/ for (i = 3; i <= max; i = i + 2) { for (j = 3; (i - (i / j) * j) != 0; j++); if (i == j) { n++; maxprime = i; } } write(fd, s, sizeof(s));//write string to file } /*** time stamp2 here ***/ t = time(NULL); printf("End time: %s", ctime(&t)); close(fd); }