user15334: I was creating Arduino function which sends two int and additional chars between them and at the beginning and end of char array - then print that array to the serial port in almost real time. (For example "X50Y100T".)
I don't want to use String object in Arduino and I found two possible solutions:

Using sprintf():
char sendBuffer[16];
void dataSend(int first, int second) {
  sprintf(sendBuffer, "X%dY%dT", first, second);
  Serial.println(sendBuffer);
};

Or something like this:
char sendBuffer[16];
void dataSend(int first, int second){
  char convert[6];
  sendBuffer[0] = 'X';

  itoa(first, convert, 10);
  strcat(sendBuffer, convert);

  sendBuffer[strlen(sendBuffer)] = 'Y';

  itoa(second, convert, 10);
  strcat(sendBuffer, convert);

  sendBuffer[strlen(sendBuffer)] = 'T';

  Serial.println(sendBuffer); 
  memset(sendBuffer,0,sizeof(sendBuffer));
};


My question is - which one is better from technical point of view?
The sprintf() looks better but it increases the sketch size by ~1,5KB. Are there any other drawbacks of sprintf()? The second solution do many things to achieve same thing and I don't know if it's efficient... Maybe there are other solutions for sending this kind of char array?

user3917: Here's a method that for some reason uses slightly fewer bytes of flash memory than Majenko's does, while producing the same output:
Add #include <Streaming.h> at the beginning of the program, and replace the five statements shown in Majenko's answer with the following line:
Serial << 'X' << first << 'Y' << second << 'T' << endl;

That is, use the Streaming.h contributed library, which adds some “syntactic sugar” to Arduino C.  At compile time it converts C++-like << Serial stream operators to Serial.print statements, without increasing code size.  You can install it via Streaming5.zip from arduiniana.org.
When the #if-delimited sections in the program shown below are selected individually (by changing two of the three 01's at a time to 0's), I got the following compiled-code and RAM figures, running the program on a Nano, where all three ways appear to give the same output:
      Bytes  Bytes
Alt.  Flash   Ram    Note
 1    2,204   182    Five Serial.print stmts
 2    3,384   190    Using snprintf()
 3    2,176   182    One Streaming stmt

I don't know whether this slight decrease (from 2204 to 2176 bytes of flash) is replicable, but the method probably is worth trying in your situation.
The program:
#include <Streaming.h>
void setup() {
  Serial.begin(115200);
}
void loop() {
  int first=50, second=100;
  //enum { first=50, second=100};
#if 01
  Serial.print('X');
  Serial.print(first);
  Serial.print('Y');
  Serial.print(second);
  Serial.println('T');
#endif
#if 01
  char sendBuffer[16];
  snprintf(sendBuffer, sizeof sendBuffer, "X%dY%dT", first, second);
  Serial.println(sendBuffer);
#endif
#if 01
  Serial << 'X' << first << 'Y' << second << 'T' << endl;
#endif
}

Note, I used snprintf() rather than sprintf() because it's easier to avoid buffer overruns with snprintf() than with sprintf(). 

user4143: Why do you feel you need to use either method? Neither are needed. Just print the individual parts:
Serial.print('X');
Serial.print(first);
Serial.print('Y');
Serial.print(second);
Serial.println('T');

No intermediate buffers, just sending the data direct out to the UART.

15334: <p>I was creating Arduino function which sends two <code>int</code> and additional <code>char</code>s between them and at the beginning and end of <code>char</code> array - then print that array to the serial port in almost real time. (For example "X50Y100T".)</p>

<p>I don't want to use <code>String</code> object in Arduino and I found two possible solutions:</p>

<ul>
<li><p>Using <code>sprintf()</code>:</p>

<pre><code>char sendBuffer[16];
void dataSend(int first, int second) {
  sprintf(sendBuffer, "X%dY%dT", first, second);
  Serial.println(sendBuffer);
};
</code></pre></li>
<li><p>Or something like this:</p>

<pre><code>char sendBuffer[16];
void dataSend(int first, int second){
  char convert[6];
  sendBuffer[0] = 'X';

  itoa(first, convert, 10);
  strcat(sendBuffer, convert);

  sendBuffer[strlen(sendBuffer)] = 'Y';

  itoa(second, convert, 10);
  strcat(sendBuffer, convert);

  sendBuffer[strlen(sendBuffer)] = 'T';

  Serial.println(sendBuffer); 
  memset(sendBuffer,0,sizeof(sendBuffer));
};
</code></pre></li>
</ul>

<p>My question is - which one is better from technical point of view?</p>

<p>The <code>sprintf()</code> looks better but it increases the sketch size by ~1,5KB. Are there any other drawbacks of <code>sprintf()</code>? The second solution do many things to achieve same thing and I don't know if it's efficient... Maybe there are other solutions for sending this kind of <code>char</code> array?</p>
 3917: <p>Here's a method that for some reason uses slightly fewer bytes of flash memory than Majenko's does, while producing the same output:</p>

<p>Add <code>#include &lt;Streaming.h&gt;</code> at the beginning of the program, and replace the five statements shown in Majenko's answer with the following line:</p>

<pre><code>Serial &lt;&lt; 'X' &lt;&lt; first &lt;&lt; 'Y' &lt;&lt; second &lt;&lt; 'T' &lt;&lt; endl;
</code></pre>

<p>That is, use the <code>Streaming.h</code> <a href="https://www.arduino.cc/en/Reference/Libraries" rel="nofollow">contributed library</a>, which adds some “syntactic sugar” to Arduino C.  At compile time it converts C++-like <code>&lt;&lt;</code> Serial stream operators to <code>Serial.print</code> statements, without increasing code size.  You can install it via <a href="http://arduiniana.org/Streaming/Streaming5.zip" rel="nofollow"><code>Streaming5.zip</code></a> from <a href="http://arduiniana.org/libraries/streaming/" rel="nofollow">arduiniana.org</a>.</p>

<p>When the <code>#if</code>-delimited sections in the program shown below are selected individually (by changing two of the three 01's at a time to 0's), I got the following compiled-code and RAM figures, running the program on a Nano, where all three ways appear to give the same output:</p>

<pre><code>      Bytes  Bytes
Alt.  Flash   Ram    Note
 1    2,204   182    Five Serial.print stmts
 2    3,384   190    Using snprintf()
 3    2,176   182    One Streaming stmt
</code></pre>

<p>I don't know whether this slight decrease (from 2204 to 2176 bytes of flash) is replicable, but the method probably is worth trying in your situation.</p>

<p>The program:</p>

<pre><code>#include &lt;Streaming.h&gt;
void setup() {
  Serial.begin(115200);
}
void loop() {
  int first=50, second=100;
  //enum { first=50, second=100};
#if 01
  Serial.print('X');
  Serial.print(first);
  Serial.print('Y');
  Serial.print(second);
  Serial.println('T');
#endif
#if 01
  char sendBuffer[16];
  snprintf(sendBuffer, sizeof sendBuffer, "X%dY%dT", first, second);
  Serial.println(sendBuffer);
#endif
#if 01
  Serial &lt;&lt; 'X' &lt;&lt; first &lt;&lt; 'Y' &lt;&lt; second &lt;&lt; 'T' &lt;&lt; endl;
#endif
}
</code></pre>

<p>Note, I used <code>snprintf()</code> rather than <code>sprintf()</code> because it's easier to avoid buffer overruns with <code>snprintf()</code> than with <code>sprintf()</code>. </p>
 4143: <p>Why do you feel you need to use either method? Neither are needed. Just print the individual parts:</p>

<pre><code>Serial.print('X');
Serial.print(first);
Serial.print('Y');
Serial.print(second);
Serial.println('T');
</code></pre>

<p>No intermediate buffers, just sending the data direct out to the UART.</p>
