[Solved] Weird issue in C [closed]


This is taken from your code:

char *compar;
if(i==0){
    sprintf(&compar,"%c%c%c%c",code[0],code[1],code[2],code[3]);
}

The problem here is that you declare compar as a pointer to char, but it is uninitialized. So, it has an undefined value. When you fill it with sprintf, you just write somewhere in the memory, and apparently, you write over the variable nombre_instruction.

Solution:

char compar[200]; 

solved Weird issue in C [closed]