I am trying to read a csv file that is all integers, and there's no header. The first line is just the first list of integers that I need. Right now I'm trying to read them in with a while loop and add them to an array but I'm getting 0,0 every time and that is not the correct value
char * file = argv[1];
FILE * fp = fopen(file, "r");
if (!fp) {
printf("File not found!\n");
}
while (fp) {
int * x = malloc(sizeof(int));
int * y = malloc(sizeof(int));
fscanf(fp, "%d,%d", x, y);
printf("%d, %d\n", *x, *y);
}
The format of the csv is
2,4
13,6
etc.
Update: I removed the while loop and it correctly grabbed the first value, am I incrementing my fp incorrectly or something?