char *textMessages[] = { "Small text message","Slightly larger text message","A really large text message that " "is spread over multiple lines" }@H_403_3@ 如何确定特定字符串字面量的长度 – 说第三个字符串?我已经尝试使用sizeof命令如下: int size = sizeof(textMessages[2]);@H_403_3@ 但结果似乎是数组中的指针数,而不是字符串文字的长度.
如何确定特定字符串字面量的长度 – 说第三个字符串?我已经尝试使用sizeof命令如下:
int size = sizeof(textMessages[2]);@H_403_3@ 但结果似乎是数组中的指针数,而不是字符串文字的长度.
但结果似乎是数组中的指针数,而不是字符串文字的长度.
sizeof "A really large text message that " "is spread over multiple lines";@H_403_3@ 你可能想使用一个宏来避免重复这个长的文字,尽管如此: #define LONGLITERAL "A really large text message that " \ "is spread over multiple lines"@H_403_3@ 请注意,sizeof返回的值包括终止NUL,因此比strlen多一个.
你可能想使用一个宏来避免重复这个长的文字,尽管如此:
#define LONGLITERAL "A really large text message that " \ "is spread over multiple lines"@H_403_3@ 请注意,sizeof返回的值包括终止NUL,因此比strlen多一个.
请注意,sizeof返回的值包括终止NUL,因此比strlen多一个.