“Printf n caracteres C” Respostas de código

Printf n caracteres C

// Only 5 characters printed. When using %.*s, add a value before your string variable to specify the length.
printf("Here are the first 5 characters: %.*s\n", 5, mystr); //5 here refers to # of characters
Grotesque Gazelle

Printf n caracteres C

// Only 5 characters printed
const char * mystr = "This string is definitely longer than what we want to print.";
printf("Here are first 5 chars only: %.5s\n", mystr);
Grotesque Gazelle

Respostas semelhantes a “Printf n caracteres C”

Perguntas semelhantes a “Printf n caracteres C”

Mais respostas relacionadas para “Printf n caracteres C” em C

Procure respostas de código populares por idioma

Procurar outros idiomas de código