I am new to c. I have a problem where I can't get two pointers to point to the same space in memory. Here is some code.
struct IO{
int val;
char* name;
};
struct Gate{
enum GateType type;
struct Gate* next;
int numInputs;
struct IO* outputs;
struct IO* inputs;
};
in the main I have
struct Gate* tempGate;
tempGate = (struct Gate*)malloc(sizeof(struct Gate));
struct IO* IOList;
IOList = (struct IO*)malloc(sizeof(struct IO)*20);
tempGate->inputs = (struct IO*)malloc(sizeof(struct IO*)*2);
tempGate->outputs = (struct IO*)malloc(sizeof(struct IO*));
later in a nested for loop we have this
tempGate->inputs[j] = IOList[i];
now when I change the value of IOList[i], shouldn't tempGate->inputs[j] change as well? If not why? How can I make this the case? Help me Codiwan You're my only hope.