strlen的函數實現(linux)如下:
378/** 379 * strlen - Find the length of a string 380 * @s: The string to be sized 381 */ 382size_t strlen(const char *s) 383{ 384 const char *sc; 385 386 for (sc = s; *sc != '/0'; ++sc) 387 /* nothing */; 388 return sc - s; 389}
sizeof是在編譯的時候就已經確定好的大小。