I was wondering if there is any way to ignore whitespace with either the fscanf or fgets function. My text file has two chars on each line that may or may not be separated by a space. I need to read the two chars and place each one in a different array.
file = fopen(argv[1], "r");
if ((file = fopen(argv[1], "r")) == NULL) {
printf("\nError opening file");
}
while (fscanf(file, "%s", str) != EOF) {
printf("\n%s", str);
vertexArray[i].label = str[0];
dirc[i] = str[1];
i += 1;
}
fscanf(file, " %c %c", &str[0], &str[1])
? – Imeldaimelida