M
M
Maqsat Batyrqul2015-11-22 21:31:25
C++ / C#
Maqsat Batyrqul, 2015-11-22 21:31:25

How to combine two different variables into one?

for example if int x = 5 ; char y = 'A' ;
and the result was currents
return 5A;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MiiNiPaa, 2015-11-22
@Maqsat

Convert both variables to strings and concatenate them.

O
Oleg Tsilyurik, 2015-11-23
@Olej

int x = 5 ; 
char y = 'A' ; 
char ret[] = { '0'+x, y, '\0' };

that's your whole line
want to return ? ;-) :
return string( ret );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question