So the max line size is 171 (including the newline).
No output from the second program means that all lines have 15 fields, which is good.
head is just another program. Just run head pseudo_facebook.tsv
Here's a program that shows the maximum size for each field, as well as the maximum line size.
It also demonstrates how we would access the fields (using strtok).
Post it's output, too, and consider how you would modify it for your task.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXLINE 1000
#define NUMFIELDS 15
int main() {
FILE *f = fopen("pseudo_facebook.tsv", "r");
if (!f) { perror("fopen"); exit(EXIT_FAILURE); }
char line[MAXLINE];
int maxfields[NUMFIELDS] = {0};
int maxline = 0;
while (fgets(line, MAXLINE, f) != NULL) {
int len = strlen(line);
if (len > maxline) maxline = len;
char *tok = strtok(line, "\t\n");
int i = 0;
while (tok) {
int len = strlen(tok);
if (len > maxfields[i]) maxfields[i] = len;
tok = strtok(NULL, "\t\n");
i++;
}
}
printf("%3d: ", maxline);
for (int i = 0; i < NUMFIELDS; i++)
printf("%3d ", maxfields[i]);
putchar('\n');
fclose(f);
return 0;
}