Here is my struct;
typedef struct _values {
int contents[MAX_CONTENTS];
... more ints;
} values;
In another function, I initialize this particular array with;
int contents[MAX_CONTENTS] = {0};
for (i = 0; i < MAX_CONTENTS; i++) {
v.contents[i] = contents[i];
}
And in my main I have this;
values v;
newValues (v);
I am getting the error whenever I try to modify an element in main like this;
v.contents[30] = 3;
This is the only error I am getting. What am I doing wrong?
v(andcontentsinside of it) may be getting passed by value. Change the prototype of your function to this:Change how you’re calling it to this:
And rather than:
Use: