I'm a university first year student, i have some question about the C programing language. My question show below
1)Write a C program to read an integer and a floating point number from the console and write them to a text file called "exercise3.txt"
my solution is
#include<stdio.h>
void main()
{
int i;
float f;
FILE *ofp;
printf("Please enter an integer number\n");
scanf("%d", &i);
printf("Please enter a floating point number\n");
scanf("%f", &f);
ofp = fopen("exercise3.txt", "w");
fprintf(ofp, "%d \n %f", i, f);
}
the exercise.txt file will automatic create, but the value i and f didn't write to the file.... how to solve this
Thank you