I was wondering how to read data from a text file that has its data separated by a comma; for example line 1 of the text file says: (Name,Integer,Integer).
So I tried using this code to read the code in but it didn't work:
while (fscanf(ifp, "%15s,%d,%d", stationName, &stationDistance, &stationDirection ) == 2) { strcpy(q[fileCounter].name, stationName); q[fileCounter].distance = stationDistance; q[fileCounter].direction = stationDirection; printf ("Station Name: %s \t Distance to Central: %d \t Direction from Central: %d \n", q[fileCounter].name, q[fileCounter].distance, q[fileCounter].direction); fileCounter++; }