Sizeof vs Strlen
问题 #include \"stdio.h\" #include \"string.h\" main() { char string[] = \"october\"; // october is 7 letters strcpy(string, \"september\"); // september is 9 letters printf(\"the size of %s is %d and the length is %d\\n\\n\", string, sizeof(string), strlen(string)); return 0; } Output: the size of september is 8 and the length is 9 Is there something wrong with my syntax or what? 回答1: sizeof and strlen() do different things. In this case, your declaration char string[] = "october"; is the same as