fp is file pointer to a file containing 100 integers. Why segmentation fault ?
FILE *fp;
if ((fp = fopen(argv[2], "r")) == NULL) {
    perror("fopen");
    exit(1);
}

for (;;) {
    int num = (random() * 99) / RAND_MAX;
    fseek(fp, SEEK_SET, num);
    char *ptr = NULL;
    fgets(ptr, 8, fp);
    int rand_num_read = strtol(ptr, NULL, 10);
    fprintf(stderr, "%d\n", rand_num_read);
}