Q:

C code for reading numbers from a file

I want to read all integers from a file and put them all in an array
 ./prog input.txt

where input.txt contains for example the following numbers
 -6 8 9 0 45 54 67 0 12
 23 3 -25 12 67 6 9 -9

How to do this without knowing the number of integer in advance
thanks for anyone answer ! 

A:

Something like this. ( Not tested)
while(!feof(inFile)){ //inFile is your pointer to the file opened with fopen()
    fscanf(inFile,"%d",&a[i]); //a is your array
    i++;
}

This way in your i variable you will have the number of items in the file (+1) and you'll get all numbers in the array.