user27240: I just yesterday started programming on Arduino, and I have a little problem. 
I want to print "#S|SKAITYMAS|[1]#" in one line, except instead of "1" I would like to use an int value. However, this one doesn't work:
Serial.println ("#S|SKAITYMAS|[",LINENR,"]#");
Any hint or tips would be appreciated.

user27157: Do something like this:
Start with your string and integer:
String string = "PI is equal to ";
int integer   = 3.1416;

Then put this in your loop:
Serial.print(string);  //string here
Serial.print(integer); //int here

Serial.println();      //change line

Serial.print() doesn't change line. Its Serial.println() which is the print that changes line so everything that is printed without println will be on the same line.

user7508: The answer by canadiancyborg is fine. However, it is always better to avoid using String objects if at all possible, because they use dynamic memory allocation, which carries some risk of memory fragmentation. Simple and safe:
int answer = 42;
Serial.print("The answer is ");
Serial.println(answer);

The only drawback is that the constant string ("The answer is ") takes some RAM. This can be avoided by embedding it in the F() macro, which means “keep this in Flash memory only”. Then, the most memory-friendly idiom is:
int answer = 42;
Serial.print(F("The answer is "));
Serial.println(answer);


27240: <p>I just yesterday started programming on Arduino, and I have a little problem. </p>

<p>I want to print <code>"#S|SKAITYMAS|[1]#"</code> in one line, except instead of <code>"1"</code> I would like to use an int value. However, this one doesn't work:</p>

<p><code>Serial.println ("#S|SKAITYMAS|[",LINENR,"]#");</code></p>

<p>Any hint or tips would be appreciated.</p>
 27157: <p>Do something like this:</p>

<p>Start with your string and integer:</p>

<pre><code>String string = "PI is equal to ";
int integer   = 3.1416;
</code></pre>

<p>Then put this in your loop:</p>

<pre><code>Serial.print(string);  //string here
Serial.print(integer); //int here

Serial.println();      //change line
</code></pre>

<p>Serial.print() doesn't change line. Its Serial.println() which is the print that changes line so everything that is printed without println will be on the same line.</p>
 7508: <p>The answer by canadiancyborg is fine. However, it is always better to avoid using String objects if at all possible, because they use dynamic memory allocation, which carries some risk of memory fragmentation. Simple and safe:</p>

<pre><code>int answer = 42;
Serial.print("The answer is ");
Serial.println(answer);
</code></pre>

<p>The only drawback is that the constant string ("The answer is ") takes some RAM. This can be avoided by embedding it in the <code>F()</code> macro, which means “keep this in Flash memory only”. Then, the most memory-friendly idiom is:</p>

<pre><code>int answer = 42;
Serial.print(F("The answer is "));
Serial.println(answer);
</code></pre>
