How to read all numbers in a file: ======================== FILE *pInp; // Variable to hold the input file pInp =fopen("C:/Documents and Settings/dabuaiadah/Desktop/teaching/c_142/ass3/inputdata.txt","r"); st = fscanf(pInp,"%d",&i); while (st != EOF) { printf("%d\n",i); st = fscanf(pInp,"%d",&i); } =================================================== Notice: EOF= -1. Diab. --------------------------------------------------------------------------------