int main(){
int x;
int y = 1;
int minNumber = min(x,y);
cout << minNumber;
return 0;
}
I know x and y are different initialization. But I do not know what excatly happen when I call min() function. Thanks for your time.
int main(){
int x;
int y = 1;
int minNumber = min(x,y);
cout << minNumber;
return 0;
}
I know x and y are different initialization. But I do not know what excatly happen when I call min() function. Thanks for your time.
It is undefined behavior because x
is uninitialized non static local variable.
x is not initialized and hence it would have some value as per what's there in memory location which is assigned for x, by the system. min function's return value will be unpredictable, in this case.