F
FaXiA
Hi all,
I'm working on a program that reads a structure from a file (1000
records).
The file read part works great, but I'm hitting a roadblock
on howto read the data from the pointer.
I'm aware that *(&WordPtr+(i*5)) gives me the AddrID at location of i
(0-999)
What is the right way of getting AddrName at for example struct row 50?
Thanks.
// parts of code.. :
struct AddrData {
unsigned int AddrID;
char AddrName[15];
};
struct AddrData Addr;
struct Addr *AddrPtr;
int i;
// allocate memory
AddrPtr = malloc(sizeof(Addr)*1000);
// open file, read data
fread(&AddrPtr, sizeof(struct AddrData), 1000, filePtr);
I'm working on a program that reads a structure from a file (1000
records).
The file read part works great, but I'm hitting a roadblock
on howto read the data from the pointer.
I'm aware that *(&WordPtr+(i*5)) gives me the AddrID at location of i
(0-999)
What is the right way of getting AddrName at for example struct row 50?
Thanks.
// parts of code.. :
struct AddrData {
unsigned int AddrID;
char AddrName[15];
};
struct AddrData Addr;
struct Addr *AddrPtr;
int i;
// allocate memory
AddrPtr = malloc(sizeof(Addr)*1000);
// open file, read data
fread(&AddrPtr, sizeof(struct AddrData), 1000, filePtr);