Hi,
e.g.
int a = 20;
int b = 07;
I want to joint a and b together to get 2007.
Anybody know how to do it?
lots of help,
ken js
Hi,
e.g.
int a = 20;
int b = 07;
I want to joint a and b together to get 2007.
Anybody know how to do it?
lots of help,
ken js
Like multiplying a by 100 perhaps?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Not very generic. I think what you want is to convert both to strings and concatenate them. As in:
Code:std::ostringstream str; str << a << b; std::cout << str.str() << std::endl;
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
Or the answers on other forums - enjoy the variety in the answers.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
It always amazes me how easy it is to overlook these things.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
Or, the convoluted way:
Output 20,0,7 to a txt. file(app), close, reopen the file then retrieve as a string.