Moderator: igrr
#include <stdio.h>
char buffer[50];
char* s = "geeksforgeeks";
void setup() {
Serial.begin(115200);
// Counting the character and storing
// in buffer using snprintf
int j = snprintf(buffer, 14, "%s\n", s);
// Print the string stored in buffer and
// character count
printf("string:\n%s\ncharacter count = %d\n", buffer, j);
// return 0;
}
void loop()
{
}
and what I got in the serial monitor:
string:
but I got no buffer contents! Any idea what happened to the buffer contents?
Loop() is your main() with an eternal built-in loop
So, the correct way to construct your sketch is discussd here:
https://www.arduino.cc/en/tutorial/sketch
The Arduino IDE installs switch examples, too.