c++arraysstringstring-literalsnull-terminated

Are string literals null-terminated?


Which of the following are null-terminated string?

char *str1 = "This is a string.";
char *str2 = "This is a string.\0";
char str3[] = "This is a string.";
const char *str4 = "This is a string.";
const char *str5 = "This is a string.\0";
const char str6[] = "This is a string.";

Solution

  • Also :