g****e 发帖数: 172 | 1 char *words[] = {"stately", "plump", "buck", "mulligan"};
// calculate how many elements in words
size_t words_size = sizeof(words)/sizeof(char *);
为什么不是直接 size_t words_size = sizeof(words)? | r**d 发帖数: 316 | 2 指针(char *)具体占几个字节跟平台有关。
【在 g****e 的大作中提到】 : char *words[] = {"stately", "plump", "buck", "mulligan"}; : // calculate how many elements in words : size_t words_size = sizeof(words)/sizeof(char *); : 为什么不是直接 size_t words_size = sizeof(words)?
|
|