need some help on the subject of file handling. I have a text file with some data and need to read it into a structure. The data reads as follows :-
C11401 FOYS HARDWARE 208 BRADKIRK PLACE, WALTON SUMMIT, PRESTON, PN2 3XL 0 1094866278
This is the program so far wich just doesnt work :-
#include <stdio.h>
struct rec_create{
char type;
char cust_code[6];
char cust_name[21];
char cust_address[61];
float cust_balance;
int credit_limit;
};
void main()
{
FILE *source;
struct rec_create type3;
source = fopen("DF73VF.DAT","rt"
fread(&type3,sizeof(struct rec_create),1,source);
printf("%c\n%s\n%s\n%s\n%f\n%d",
type3.type,type3.cust_code,
type3.cust_name,type3.cust_address,
type3.cust_balance,type3.credit_limit);
}
I'm sure there is an easy solution to this, but cant get my head round it. Thanx in advance for any guidance.
C11401 FOYS HARDWARE 208 BRADKIRK PLACE, WALTON SUMMIT, PRESTON, PN2 3XL 0 1094866278
This is the program so far wich just doesnt work :-
#include <stdio.h>
struct rec_create{
char type;
char cust_code[6];
char cust_name[21];
char cust_address[61];
float cust_balance;
int credit_limit;
};
void main()
{
FILE *source;
struct rec_create type3;
source = fopen("DF73VF.DAT","rt"
fread(&type3,sizeof(struct rec_create),1,source);
printf("%c\n%s\n%s\n%s\n%f\n%d",
type3.type,type3.cust_code,
type3.cust_name,type3.cust_address,
type3.cust_balance,type3.credit_limit);
}
I'm sure there is an easy solution to this, but cant get my head round it. Thanx in advance for any guidance.