H
hpy_awad
formatting float variables to fprintf has error to my writing to
output file called rental and I do not the reason that a rabish is
written to the file instead of the actual input screen values ?
#include <stdio.h>
//part09_le01_file_processing_file_setup_ver_01_iti_r01_ch09.c
struct name {
int int___member1;
float float_member2;
char char__member3;
};
main()
{
struct name record;
FILE *fpointer;
fpointer=fopen("rental","w");
char another;
do {
input_record(&record);
fprintf(fpointer,"%4d %f %c\n",record);
printf (" \nADD ANOTHER RECORD ----> ( y / n ) : ");
scanf("\n");
scanf("%c",&another);
} while (another=='y');
return 0;
}
input_record(rec)
struct name *rec;
{
printf("\nEnter int___member1: ");
scanf("%4d",&(*rec).int___member1);
printf("\nEnter float_member2: ");
scanf("%f",&(*rec).float_member2);
printf("\nEnter char__member3: ");
scanf("\n");
scanf("%c",&(*rec).char__member3);
}
output file called rental and I do not the reason that a rabish is
written to the file instead of the actual input screen values ?
#include <stdio.h>
//part09_le01_file_processing_file_setup_ver_01_iti_r01_ch09.c
struct name {
int int___member1;
float float_member2;
char char__member3;
};
main()
{
struct name record;
FILE *fpointer;
fpointer=fopen("rental","w");
char another;
do {
input_record(&record);
fprintf(fpointer,"%4d %f %c\n",record);
printf (" \nADD ANOTHER RECORD ----> ( y / n ) : ");
scanf("\n");
scanf("%c",&another);
} while (another=='y');
return 0;
}
input_record(rec)
struct name *rec;
{
printf("\nEnter int___member1: ");
scanf("%4d",&(*rec).int___member1);
printf("\nEnter float_member2: ");
scanf("%f",&(*rec).float_member2);
printf("\nEnter char__member3: ");
scanf("\n");
scanf("%c",&(*rec).char__member3);
}