Read from file into pointer to struct

Posted by cla barzu on Stack Overflow See other posts from Stack Overflow or by cla barzu
Published on 2012-12-19T10:58:50Z Indexed on 2012/12/19 11:03 UTC
Read the original article Hit count: 179

Filed under:
|
|

I need help with pointers in C. I have to read from a file, and fill an array with pointers to struct rcftp_msg . Since now I did the next things:

struct rcftp_msg {

    uint8_t version;        
    uint8_t flags;              
    uint16_t len;       
    uint8_t buffer[512];    
};

struct rcftp_msg *windows [10];

pfile = fopen(file,"r"); // Open the file

I have to read from the file into the buffer, but I don't know how to do it.
I tried the next:

for (i = 0; i <10; i++){

leng=fread (**windows[i]->buffer**,sizeof(uint8_t),512,pfile);

} 

I think windows[i]->buffer is bad, cuz that don't work.

Sorry for my bad English :(

© Stack Overflow or respective owner

Related posts about c

    Related posts about file