But you have not opened the file? Or you have done it and you did not post it?
c has to be an int because of EOF handling.As a result atoi has to be removed.
EOF is defined . You must remove the quotes.
Check this code. Read the comments.
Code:
/*=======================*/
#include <stdio.h>
int main(void)
{
FILE* fp;
/* I named the txt file test.txt */
fp=fopen("test.txt","r");
int x[100];
int i=0;
int count = 0;
/* Read from file until EOF is reached */
while(fscanf(fp,"%d",&x[i])!=EOF) {
i++; /* Increment by one the index of the array , */
/* so that you do not overwrite what you just read */
/* Eat a comma , as salem said */
fgetc(fp);
/* Count how many numbers you read */
count++;
}
for(i=0 ; i<count ; i++)
printf("%d\n",x[i]);
/* Do not forget to close the stream */
fclose(fp);
return 0;
}