mercredi 9 mai 2018

Pointers Undefined Behavior C++ [duplicate]

This question already has an answer here:

int array[]  = { 1 , 2 , 3 };
int *pointer = a;
for ( int i  = 0; i < 3; i++ ){
    *pointer++ *= *pointer;
}

This code gets the square of all the array elements but the output differs from computer to another.

Why is this undefined behavior?

Aucun commentaire:

Enregistrer un commentaire