Hello,
struct Ip {
char *ip;
};
struct Container {
struct Ip IpList[AllowedIps];
};
void putiplist(Container *cont) {
FILE *fp;
const char sig[] = "Contain File";
fp = fopen("allowedips.lst", "wb");
if ( fp == NULL )
derror("PutIpList(): Null File Pointer");
int y = fwrite (&sig, sizeof(const char), sizeof(sig), fp);
int x = fwrite (cont, sizeof(struct Container), 1, fp);
printf("[%d-%d]-[%s]\n", y, x, cont->IpList[1].ip);
fclose(fp);
}
void getiplist(Container *cont) {
FILE *lfp;
char sig[12];
lfp = fopen("allowedips.lst", "rb");
if ( lfp == NULL )
derror("GetIpList(): Null File Pointer");
int y = fread (sig, sizeof(sig), 1, lfp);
int x = fread (&cont, sizeof(struct Container), 1, lfp);
printf("[%d-%d]-[%s]\n", y, x, cont->IpList[1].ip);
fclose(lfp);
}
Hopefully this code should explain itself, I'm trying to just save a Container structure. For some reason, this refuses to work, maybe Container is not a good struct name to use? =/
Thanks for any help.
-Drek



LinkBack URL
About LinkBacks



