Join 2 integers

Good evening

Having...

int DD;
int Dia1=1;
int Dia2=0;

How can I join at variable DD the value '10'

DD = Dia1 & Dia2; ? I don't think so...

Please let me know
Thanks on advance
Best regards

Pedro Ferrer

Good evening

Meanwhile I remembered something... and it works!

char Debug[40];
char* cstr(int Parametro){
itoa(Parametro,Debug,10);
return strdup(Debug);
}

char *concatena(char *string1, char *string2) {
strcpy(StringFinal, string1);
strcat (StringFinal, string2);
return StringFinal;
}

DD=atoi(concatena(cstr(Dia1),cstr(Dia2)));

Thanks
Best regards
Pedro Ferrer

How about remembering some math from school and doing the following?

DD = Dia1 * 10 + Dia2;

Doing it with strings is a little like going from London to Paris via New York and Singapore.

Korman

Thanks Korman

That's why I've putted the code here.
I'm always expecting that somebody knows a better way to do it.

Thanks once again
Best regards

Pedro Ferrer

If those Dia1 and Dia2 are comming from the serial port save then using chars and only use an int when joining then, as that will save you some ram.