sprintf with two char buffers >> not working?

I have two character buffers and two integers all of which i want to put together into a single char buffer as a response message in my serial command handler. Problem is the second character buffer is ignored and only the first is used twice. why?

sprintf(aMsg, "%s,%i,%i,%s", aBuf1, aInt1, aInt2, aBuf2);

I see something like: aaa,1,2,aaa

instead of: aaa,1,2,bbb

any idea what i'm missing?

maverick2013: any idea what i'm missing?

The rest of your code.

char obuf[6]; dtostrf(stateCurPos,5,1,obuf);

char obufx[5]; dtostrf(stateRotCnt,4,1,obufx);

char aMsg[40]; sprintf(aMsg,"%s,%i,%i,%s", obuf, stateDIR, stateSpeed, obufx ); cmdMessenger.sendCmd(kSTATUS, aMsg);

stateRotCnt is a float?

If you’re trying to show us a problem then you need to post a complete sketch that demonstrates it, and tell us what the sketch does that’s wrong.

Preferably a small sketch that only runs in setup(). This one's got to be easy.

I think you are overflowing these arrays.

char obuf[6];   
// the MINIMUM width is 5 (padded with blanks on the left)
// plus the terminating zero is 6
// if stateCurPos is larger than 999.9, it will overflow obuf
// and into obufx below.
dtostrf(stateCurPos,5,1,obuf);  

char obufx[5];   
// the MINIMUM width is 4 plus the terminating zero is 5
// if stateRotCnt is larger than 99.9, it will overflow obufx
// and into something else.
dtostrf(stateRotCnt,4,1,obufx);