READING FROM A FILE IN C!
Hi. I have a problem in understanding how to read a file and copy what i'm reading to an array or matrix. For example ,I have in a file : 324; 213; 231; 912 ( the integers are separated by " ; " and a space). I want to copy that into an array of integers, I know that I can do it with fscanf() function , but i don't know how. I thought about writing fscanf(filepointer, "%d; %d; %d; %d", 4 int variables); but is this correct? Would it just skip the ";" and the spaces (in the fscanf i wrote ";space" after %d) And what if there were more than 4 integers , like 100 , i shouldn't do it manually : would it become something like this : (if my prediction was correct) int a[100]; int i; for(i=0;i<100;i++) { fscanf(filepointer,"%d; ",a[i]); } Thank you so much and have a nice day!