Combining Strings and Integers into one big string

Hi there

I have an integer representing a number of seconds. What I would like to do is display this value as a string of "X hrs - Y mins - Z secs" on my LCD display. I can calculate the individual values of the hrs, mins and secs. However, I don't know how to combine integers and strings (chars) to one string, for use with printIn(). Something like this:

my_string[] = {my_hrs & "hrs" & my_mins & "mins" & my_secs & "secs"}

Any ideas?

You could use a standard C library function like sprintf but it brings in almost 2k of code and is not very intuitive to use.
I prefer something like this to handle the formatting

void printTime( int hrs, int mins, int secs){
lcd.printInt(hrs);
lcd.println(" hrs “);
lcd.printInt(mins);
lcd.println(” mins “);
lcd.printInt(secs);
lcd.println(” secs");
}

// function to print an integer to the lcd
void printInt(long n){
byte buf[10]; // prints up to 10 digits
byte i=0;
if(n==0)
lcd.print(‘0’);
else{
if(n < 0){
lcd.print(’-’);
n = -n;
}
while(n>0 && i <= 10){
buf[i++] = n % 10; // n % base
n /= 10; // n/= base
}
for(; i >0; i–)
lcd.print((char) (buf[i-1] < 10 ? ‘0’ + buf[i-1] : ‘A’ + buf[i-1] - 10));
}
}

@mem: Very nice, thank you! A printInt function was the second option I was looking for. I will try this out. It also helps me to get rid of the itoa() function I was using for something similar.