首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序: #include <iostream> #include <strinq> using namespace std; int main() { char a[] = {’a’/’b’/’c’/’
有以下程序: #include <iostream> #include <strinq> using namespace std; int main() { char a[] = {’a’/’b’/’c’/’
admin
2010-03-29
16
问题
有以下程序: #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; } 程序运行后的结果是( )。
选项
A、9,9
B、8,9
C、1,8
D、9,8
答案
8
解析
本题考查sizeof运算符和字符串函数strlen()的区别。
①sizeof运算符返回其后表达式或类型标识符所表示的数在内存中所占的字节数。
②函数strlen()的功能是返回string的长度,但不包括结束字符’\0’。
字符数组a在内存中所占的字节数为9。而字符数组a中不包括结束字符’\0’的字符数为8。
转载请注明原文地址:https://jikaoti.com/ti/3iW0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
设有定义:doublea,b,c;若要求通过输入分别给a、b、c输入1、2、3,输入形式如下(注:此处□代表一个空格)□□1.0□□2.0□□3.0则能进行正确输入的语句是
若有说明inta[3][4];则a数组元素的非法引用是()。
下列给定程序中,函数fun的功能是:把形参a所指数组中的最小值放在元素a[0]中,接着把a所指数组中的最大值放在a[1]元素中;再把a所指数组元素中的次小值放在a[2]中,把a所指数组元素中的次大值放在a[3],以此类推。例如,若a所指数组中的数据最初排
有三个关系R、S和T如下:则由关系R和S得到关系T的操作是()。
下面结构体的定义语句中,错误的是()。
设fp为指向某二进制文件的指针,且已读到此文件末尾,则函数feof(fp)的返回值为()。
有三个关系R、S和T如下:由关系R和S通过运算得到关系T,则所使用的运算为()。
下列关于逻辑运算符两侧运算对象的叙述中正确的是()。
以下关于逻辑运算符两侧运算对象的叙述中正确的是
随机试题
中华人民共和国第一部《著作权法》颁布于()年。
下列不需要激素冲击治疗的是
第三代头孢菌素的特点是
从一定意义上说,投资建设规模约束和决定着工程咨询的()
某工程项目,建设单位通过招标选择一个咨询单位承担施工招标代理和施工阶段监理工作,并在监理中标通知书发出后第45天,与该咨询单位签订了委托监理合同。之后双方又另行签订了一份监理酬金比监理中标价降低10%的协议。在施工公开招标中,有A、B、C、D、E、F、G
对于我国商业银行所从事的基金业务,其监管主体是()
江西省“十一五”期间进出口总额为()。
某商店卖出一支钢笔的利润是9元,一瓶墨水的进价是2元。若采用“买4支钢笔送一瓶墨水”的方式促销,共获利1922元,则这次促销最多卖出多少支钢笔?
A、条件(1)充分,但条件(2)不充分。B、条件(2)充分,但条件(1)不充分。C、条件(1)和(2)单独都不充分,但条件(1)和条件(2)联合起来充分。D、条件(1)充分,条件(2)也充分。E、条件(1)和(2)单独都不充分,条件(1)和条件(2
阅读以下说明,回答下列问题,将解答填入答题纸对应的解答栏内。【说明】某网络拓扑结构如图1—1所示,网络中心设在图书馆,均采用静态IP接入。该网络在进行IP地址部署时,可供选择的地址块为192.168.100.0/26,各部门计算
最新回复
(
0
)