I have a simple converting function however the variable is changing.
void convert_print(std::string type,int num)
{
if(type=="oct"){
std::cout << num << " oct value is: " << std::oct << num << endl;
}
else if(type == "hex"){
std::cout << num << " hex value is: " << std::hex << num << endl;
}
}
int main()
{
int num = 30;
convert_print("hex",num);
convert_print("oct",num);
}
Prints
30 hex value is: 1e
1e value is: 30
Why is num
getting changed to 1e when I call the function again. I never reassigned num