首页 > 试题广场 >

有如下一段代码,下列选项中,选项()是该段代码的正确输出。

[单选题]
有如下一段代码,下列选项中,选项()是该段代码的正确输出。
#include<stdio.h>
#include<string.h>
#define PRAISE "NowCoder is benefit to everyone concerned."

int main(){
    printf("The phrase of PRAISE has %zd letters ",strlen(PRAISE));
    printf("and occupies %zd memory cells.",sizeof(PRAISE));
    return 0;
}
  • The phrase of PRAISE has 42 letters and occupies 42 memory cells.
  • The phrase of PRAISE has 42 letters and occupies 43 memory cells.
  • The phrase of PRAISE has 43 letters and occupies 42 memory cells.
  • The phrase of PRAISE has 43 letters and occupies 43 memory cells.
sizeof会将末尾的\0也计入,strlen只计算\0之前的字符串长度
发表于 2025-10-16 12:13:52 回复(0)