C coding in arduino

i have a simple question. in C programming i used to write this,
printf("value : %d", value);
if value = 13. so it will print, "value : 13"

so, my question, how to write similar coding, but this time for char instead of decimal. thanks in advance.

char myBuffer[32] = ""
sprintf(myBuffer, ""value : %d", value);
Serial.println(myBuffer);

make sure not to overflow myBuffer (or use snprintf())

Since 13 is a non-printing character, and is a carriage return, I'm not sure how the Serial object would handle it. However, the following program does show that the monitor does properly handle displaying a simple char:

void setup() {
  char c;

  c = 10;               // A line feed, which should be visible

  Serial.begin(9600);
  Serial.print("this should be followed by two blank lines:");
  Serial.print(c);
  Serial.print(c);
  Serial.print("Now a new line.");
  
}

void loop() {

}

econjack:
Since 13 is a non-printing character, and is a carriage return, I'm not sure how the Serial object would handle it.

the format specifier kind-of suggests that value is a signed integer...

thanks guys. that helps me.
i use String instead of char, so it becomes

String word = "Aigoo";
Serial.print("The word is " + word);

the ouput is:
"The word is Aigoo"

btw, thanks guys :slight_smile:

rafiuddin:
thanks guys. that helps me.
i use String instead of char, so it becomes

String word = "Aigoo";
Serial.print("The word is " + word);

the ouput is:
"The word is Aigoo"

btw, thanks guys :slight_smile:

so that's a lot different than a char!

BTW, the format specifier for a char is c (e.g. %c)
I'll leave it to you to look up the format specifier for your string