serial.print and string

Can someone help!
I need the data that is sent to Serial.printf be combined and contain as a whole.
When i try and do the code without the string and Serial.printf working its correct but when i try to combile the answers togather using string it doesent help.

My code:

String MAC_and_RSSI = "";
    for(int i=0;i<5;i++) {
      ///////Serial.printf("%02x:",buf[22+i]);
      MAC_and_RSSI += "%02x:",buf[22+i];  
    }
    ////////Serial.printf("%02x  ",buf[22+5]);
    MAC_and_RSSI += '"%02x  ",buf[22+5]';
    // Signal strength is in byte 0
    //////Serial.printf("%i\n",int8_t(buf[0]));
    MAC_and_RSSI += "%i\n",int8_t(buf[0]);

    Serial.print(MAC_and_RSSI);

if anyone can do it another way im happy.
Thanks!

Which Arduino are you using and does it support the use of printf() ?

UKHeliBob:
Which Arduino are you using and does it support the use of printf() ?

I use esp8266 and it does support serial.printf();

 MAC_and_RSSI += "%02x:", buf[22 + i];

MAC_and_RSSI += '"%02x  ",buf[22+5]';

MAC_and_RSSI += "%i\n", int8_t(buf[0]);

I am not clear what these lines of code are intended to do.

The second one is particularly odd.

UKHeliBob:

 MAC_and_RSSI += "%02x:", buf[22 + i];

MAC_and_RSSI += '"%02x  ",buf[22+5]';

MAC_and_RSSI += "%i\n", int8_t(buf[0]);




I am not clear what these lines of code are intended to do.

The second one is particularly odd.

the whole program is meant to collect MAC adreses and then send them to a mqtt server.
dont bother about this parts ('"%02x ",buf[22+5]') i just want to know how i can combine the three answers in to one.

dont bother about this parts ('"%02x ",buf[22+5]')

But they are part of the code that you are having trouble with

It looks like you are trying to use printf style formatting with String concatenation which is not going to work.

What exactly is in the buf array and what data type is it ?

I'm having a severe brain-mangle pitching String objects into printf.

AWOL:
I'm having a severe brain-mangle pitching String objects into printf.

So is the compiler I imagine

I need the output that comes from this:

Serial.printf("%02x:",buf[22+i]); //for example output: 1
Serial.printf("%02x ",buf[22+5]); //for example output: 2
Serial.printf("%i\n",int8_t(buf[0])); //for example output: 3

to combile the answer togather example: 123
Thanks!

What do you mean by "combine"?
Concatenate?

Do a search for
man printf
man sprintf
man snprintf

If printf is a supported function for the Serial class, there is a good chance that e.g. client.printf also is supported (no experience with ESPs).

Serial.printf("%02x:",buf[22+i]);    //for example output: 1 Your "for example" is misleading - that format should never print a solitary character.