For some reason this segment of code does not do what it is supposed to.
Code:
float num;
float balance;
char filename[25];
int reg;
puts("enter registration number");
scanf(" %d",®)
sprintf(filename,"%dbal.txt",reg);
file = fopen(filename,"r");
fscanf(file,"%f",&balance);
printf("The current balance for the client is %f\n",balance);
fclose(file);
puts("enter how much you would like to add to the balance");
scanf("%f",&num);
file = fopen(filename,"w");
balance += num;
fprintf(file,"%f",balance);
fclose(file);
balance = 0;
it does everything apart from writing balance to the file