Printf - send apostrophe to UART

I am using the Bluepill board and online compiler. When I had connected serial port to the terminal, there was not a problem to send some information like:

sLCD.printf(“Restarting network…\r\n”);
sLCD.printf(“IP: %s\r\n”, wiz.getIPAddress());

In second step I want to have connected smart display on serial port. This display accept commands like this

t0.txt=“Running” (area t0 shows text Running) and this I need to send to UART.

But I don’t have idea, how to included the apostrophe into the serial message (I have tried method with single apostrophe, but no success). The UART message to this display must be something like this:

sLCD.printf('t0.txt=“Running” ');
sLCD.printf('t0.txt=" '+“IP: %s\r\n”, wiz.getIPAddress() + ’ " ');

Compiler don’t accept this construction. I get errors:
Warning: Too many characters in character literal – extra leading characters ignored in “main.cpp”, Line: 239, Col: 18
Error: Argument of type “int” is incompatible with parameter of type “const char *” in “main.cpp”, Line: 239, Col: 18

Thank you very much for your help and tips how to solve it.

Best regards Lukas


I am not sure if I understand but I am sure you can not use single quote for string, that is for a single char.

BR, Jan

Hello Lukas,

As Jan suggested, use the \ character (escape character for C style strings) to include an " (apostrophe) into a C style string. For example:

 char myString[] = "Hello, \"Lukas\"!";



printf( "Hello, \"Lukas\"!");

will print out

Hello, "Lukas"!

You can use it also to include a \ (backslash) character into a string:

printf("This is a backslash: \\ \r\n");

It is used to include other special characters like the “carriage return” (\r) and the “line feed” (\n).

Best regards, Zoltan