Hello I took all of your seggustions and fixed my code but there is still comething wrong. It seems to have an runtime error. The value of c written in the file is all wrong. Wht could be wrong with it.
Code:
#include <stdio.h>
int main()
{
int a, b, c;
FILE *out, *in;
c= a + b;
in = fopen("C:\\value.txt", "r");
out = fopen("C:\\number.txt", "w");
if(!in || !out)
{
printf("Failed to open files\n");
return 1;
}
printf("Please enter the value of B: ");
scanf("%d", &b);
fscanf(in, "%d", &a);
fprintf(out, "c is equal to %d\n", c=a+b);
fclose(out);
fclose(in);
return 0;
}