I am trying to copy a struct into an array of the same type of struct.
My structs are
typedef struct{
int mode;
int link_cnt;
int uid;
int gid;
int size;
int pointers[NUM_INODE_POINTERS];
} inode;
typedef struct{
inode inodes[MAXFILES+1];
} inode_table;
So the inode_table is a array of inodes. I then make an instance of them:
inode_table inodetable;
inode rootinode;
Initialize the inode and copy it into the array:
inode rootinode={
.mode=0777,
.link_cnt=1,
.uid=0,
.gid=0,
.size=0,
.pointers={26,0,0,0,0,0,0,0,0,0,0,0,0}
};
memcpy(inodetable[0], &rootinode, sizeof rootinode);
This does not work and I get the error at the memcpy line:
subscripted value is neither array nor pointer nor vector
How can I copy the rootinode struct into the inodetable?
inode rootinodeby the way? Initializinginodetabledirectly might be simpler otherwise.