Answer:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int arr[100];
int i = 0;
int j = 0;
char c[10];
char temp;
int sum = 0;
FILE* fp;
if ((fp = fopen("test.txt", "r")) == NULL) {
printf("cannot open the file");
return;
}
else {
do {
temp = fgetc(fp);
if (temp == ' ' || temp == '\n') {
c[j] = '\0';
arr[i++] = atoi(c);
j = 0;
continue;
}
c[j++] = temp;
} while (temp != EOF);
for (j = i - 1; j >= 0; j--) {
printf("%d\n", arr[j]);
}
}
getchar();
}
Explanation: