单选题
有以下程序: #include <iostream> #include <strinq> using namespace std; int main() { char a[] = {'a'/'b'/'c'/'d','e','f','g','h','/0'}; int i j; i=sizeof(A) ; j=strlen(A) ; cout<<i<<","<<j<<end1; return 0; } 程序运行后的结果是( )。
【正确答案】
D
【答案解析】[解析] 本题考查sizeof运算符和字符串函数strlen()的区别。
①sizeof运算符返回其后表达式或类型标识符所表示的数在内存中所占的字节数。
②函数strlen()的功能是返回string的长度,但不包括结束字符'/0'。
字符数组a在内存中所占的字节数为9。而字符数组a中不包括结束字符'/0'的字符数为8。