Combining values without adding them in c++

Hello,

I am new to c++ and I was just wondering if there is as way to combine two int variables in c++ without adding them if int1 = 0 and int2 = 1 the result will be 01 and vice versa or if int1 = 0 and int2 = 2 result will be 02 and vice versa. Final example if int1 = 2 and int2 = 1 is 21 and vice versa. For my project int1 and int2 are a value between 0 and 2 but if there is a way to do this so it will hold true for wider ranges of values that would be great.

Thanks

You would have to convert to string, concatenate, and then convert to int again. Look up the following functions: std::to_string and std::stoi.
You could convert them to a string and concatenate them. Or you could multiply one of them by 1xxxx (the number of xs being the number of digits in the second number) and then add them together. Anything is possible if you're creative enough.
Topic archived. No new replies allowed.