so I have an array that keeps getting overwritten with new values. For example, this is the output:
instruc[0] = PRINTNUM
instruc[1] = PRINTNUM
instruc[2] = PRINTNUM
where PRINTNUM is supposed to be the last thing in the array and the first two elements are supposed to be something else.
Here is my code for the specific segment:
//array of instructions
char** instruc = malloc(numLines * 200);
c = fgets(inputString, 200, in_file);
while (c != NULL){
instruc[i]=inputString;
i++;
c = fgets(inputString, 200, in_file);
}
//print out what's in the array
i=0;
for (i=0; i<numLines; i++){
printf("instruc[%d] = %s\n", i, instruc[i]);
}
Thanks in advance!