struct item {
int mod[2];
void set (int kA, int kB, int kC) {
mod[0]=kA;
mod[1]=kB;
mod[2]=kB;
}
};
and an initializing function
1 2 3
void initItems(){
itemInQuestion.set(1,2,3);
}
but no matter what value I put in the third paramater, the mod[2] value always becomes 10. When I initialize the itemInQuestion from the main, however, the mod[2] value becomes what I want it to.
Any ideas what might be causing this?
NOTE:
I changed some things, and noticed the mod[2] value is being determined by the next variable of the next function (lolwut?). IE:
Your array mod[] is an array of only two elements, accessed by mod[0] and mod[1]. Accessing mod[2] is a memory access violation. If you want an array of three elements, you have to do int mod[3];.
Also note that line 6 in your first code snippet is wrong. The right-hand side of the equal sign has to be kC, not kB.
Thanks, I just noticed the wrong array size, and now it works like a charm.
I need to stop changing my code halfway through . . .
also, is there any way to integrate cin into a function, as in