use Serial.write with a tab

hi,
I search to use the funtion Serial.write with a tab, but it work only if I créate the tab with sprintf


That work


char trame[16] = {0};

sprintf(trame,"%d",0);
for(i=0;i<15;i++)
{
sprintf(trame,"%s%d",trame,0);
}

Serial.write(trame);



That doesn't work


char trame[16] = {0};
char trame1[4] = {0,5,1,2};
char trame2[4] = {0};
char trame3[4] = {0};
char trame4[4] = {0,24,1,2};

trame[0] = trame1[0];
trame[1] = trame1[1];
trame[2] = trame1[2];
trame[3] = trame1[3];
trame[4] = trame2[0];
trame[5] = trame2[1];
trame[6] = trame2[2];
trame[7] = trame2[3];
trame[8] = trame3[0];
trame[9] = trame3[1];
trame[10] = trame3[2];
trame[11] = trame3[3];
trame[12] = trame4[0];
trame[13] = trame4[1];
trame[14] = trame4[2];
trame[15] = trame4[3];

Serial.write(trame);


Thank you very much in advance for any help.

 for(i=0;i<15;i++)
    {
        sprintf(trame,"%s%d",trame,0);
    }

This will result in trame containing "0123456789101112131415", which will NOT fit in a 16 element array.

How does sending that string result in a tab being sent?

No the result in trame containing "000000000000000\0" it's a 16 ellement array.

A tab character is a hex 09, so you need to find some way to write that.

If you want to write a tab between two numbers, I think you need to look at something like this

char buf[20] ;

int a=7 ;
int b=8 ;

sprintf(buf,"%d\t%d", a, b );

Thats what you can do in normal C/C++, there are issues with sprintf() on Arduino, but I don't know if they
affect this. The '\t' character in the format string represents a tab character.