I am newbie in C programming and I have a easy assigment but I coul not do that. I need to read two number from a file, add them, print them that is all. Here is the my code.
#include <stdio.h>
#include <stdlib.h>
int main(void) {
FILE *fp;
fp = fopen("erogol.k","r");
char a =fgetc(fp);
int aInt = atoi(&a);
char b =fgetc(fp);
int bInt = atoi(&b);
printf("%d \n",bInt+aInt);
return EXIT_SUCCESS;
}
My File has "9 4" and I need to take each number 9 and 4 them sum them but the program does not work.
Can you help me?