W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
#include
int main() { // 为字符串预留 20 字节内存 char myString[20] = "Hello World!\n"; int memorySize = sizeof(myString); int stringSize; // 打印字符串并使用 %n 测量长度 printf("%s%n\n", myString, &stringSize); // 打印字符串尺寸 printf("内存大小: %d\n", memorySize); printf("字符串长度: %d\n", stringSize); return 0; }