I have a simple struct containing an array of ints and an index to be used for that array.
#define BUFF_SIZE 100
typedef struct _buffer Buffer;
struct _buffer {
int buff[BUFF_SIZE];
int index;
};
I am trying to write a function to create a pointer to an instance of this struct, and initialise its values to zero. However when I try to initialise the array using the arrow operator I get an error that the expression is invalid.
...
Buffer* newBuff;
newBuff->buff = {0}; //Error occurs here
...
I know that in c an array is a pointer to the base of the memory block in which the array resides, but was under the impression that dereferencing the struct pointer would allow me to access the array. Am I wrong about this, or am I missing something here? I have a feeling that it is something very simple, but for the life of me I just can't spot it.
Thanks!
EDIT: Thanks for the quick answers guys, they've helped me understand some of what is occurring. I neglected to mention that this is intended to be run on an embedded system (sorry about that), so I would like to avoid using includes or malloc if at all possible.