网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
单选题
有如下程序:#include #include main(){ char name[10]=c-book; char *str=name; printf(%d,%d,%d,%d, sizeof(name), strlen(name), sizeof(str), strlen(str));}程序运行后的输出结果是(  )。
A

10,6,4,6

B

11,6,11,6

C

11,6,1,6

D

10,7,1,7


参考答案

参考解析
解析:
由一维数组初始化的知识可知,name[10] = "c-book",即name[10]="c-book\0\0\0\0"。sizeof函数用来获取类型或数据对象的长度,也即是一个这种数据类型的变量在内存中所占字节数。strlen函数统计字符串长度,遇到'\0'统计结束。字符指针变量和字符数组在内存中的存储情形不同,数组指的是按照数组长度分配的若干存储空间,在内存中字符类型变量占1个字节;而指针只是一个存储字符串首地址的存储空间,指针占4个字节。所以sizeof(name)=1×10=10,strlen(name)=6,sizeof(str)=4,strlen(str)=6。答案选择A选项。
更多 “单选题有如下程序:#include #include main(){ char name[10]=c-book; char *str=name; printf(%d,%d,%d,%d, sizeof(name), strlen(name), sizeof(str), strlen(str));}程序运行后的输出结果是(  )。A 10,6,4,6B 11,6,11,6C 11,6,1,6D 10,7,1,7” 相关考题
考题 有以下程序includeincludetypedef strtlct{char name[9];char sex;floatsc 有以下程序 #include <stdio.h> #include <string.h> typedef strtlct{ char name[9]; char sex;floatscore[2]; }STU; void f(STU A){ STU b={"Zhao",'m',85.0,90.0}; int i; strcpy(a.name,b.name); a.sex=b.sex; for(i=0;i<2;i++) a.score[i]=bA.Qian,f,95,92B.Qian,m,85,90C.Zhao,f,95,92D.Zhao,m,85,90

考题 有下列程序: include include "string.h" void tim(char *s[],int n) 有下列程序: #include <stdio.h> #include "string.h" void tim(char *s[],int n) { char *t;int i,j; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if(strlen(s[i])>strlen(s[j])) {t=s[i];s[i]=s[j];s[j]=t;} } main() { char *ss[]= {"bcc","bbcc","xy","aaaacc","aabcc"}; fun(ss,5);printf("%s,%s\n",ss[0],ss[4]); } 程序的运行结果是( )。A.xy,aaaaccB.aaaacc,xyC.bcc,aabccD.aabcc,bcc

考题 阅读下列程序,则在执行后,程序的运行结果为#include "stdio.h"#include "string.h"main(){ char a[30]="nice to meet you!";strcpy(a+strlen(a)/2,"you");printf("%s\n",a);}A.nice to meet you youB.nice toC.meet you youD.nice to you

考题 有以下程序:includeincludeincludevoid f(char*s,char*t){char k;k=*s; * 有以下程序: #include<stdio.h> #include<string.h> #include void f(char*s,char*t) { char k; k=*s; *s=*t; *t=k; s++;t--; if(*s)f(s,t): } main() {char str[10]="abcdefg",*P; P=str+strlen(str)/2+1: f(p,p-2); printf("%s\n",str); } 程序运行后的输出结果是( )。A.abcdefgB.gfedcbaC.gbcdefaD.abedcfg

考题 有以下程序: include point ( char * p) {p + = 3; }main( ) char b[4] = {'a','b','c 有以下程序: #include <stdio.h>point ( char * p) { p + = 3; }main( ) char b[4] = {'a','b','c','d'} , *p=b; point(p); printf( "% c \n" , * p);A.aB.bC.cD.d

考题 下面程序的输出结果是( )。 include main() {static char a[]="china"; char*ptr=a; whi 下面程序的输出结果是( )。 include<stdio.h> main() {static char a[]="china"; char*ptr=a; while(*ptr) {printf("%c",*ptr-32); ptr++; } }

考题 以下程序的输出结果是【】。 include include void main 0 { char s[50]; st 以下程序的输出结果是【 】。include<iostream.h>include <string.h>void main 0 {char s[50];strcpy(s[O], "No" );strcpy(s[1], "123" );strcpy (s[2], "23456" );cout<<s;}

考题 下列程序的输出结果是【】。 include include void main(){ char b[30]; str 下列程序的输出结果是【 】。include<iostream.h>include<string.h>void main(){char b[30];strcpy(b[0],"XY");strcpy(b[1],"YZW");strcpy(b[2],"ZXY");cout<<b<<end1;}

考题 以下程序的输出结果是()includeincludemain(){char str[12]={'s','t','r', 以下程序的输出结果是( ) #include<stdio.h> #include<string.h> main() {char str[12]={'s','t','r','i','n','g'}; printf("%d\n",strlen(str)); }A.6B.7C.11D.12

考题 下列程序的运行结果是()。 include include main() {char*s1="abDuj"; char 下列程序的运行结果是( )。#include<stdio.h>#include<string.h>main(){ char*s1="abDuj";char*s2="ABdUG";int t;t=strcmp(s1,s2) ;printf("%d",t);}A.正数B.负数C.零D.不确定的值

考题 有以下程序 include include typedef struct { cha 有以下程序 #include <stdio.h> #include <string.h> typedef struct { char name[9]; char sex; float score[2]; } STU; STU f(STU a) { STU b={"Zhao", 'm', 85.0, 90.0}; int i; strcpy(a.name, b.name); a.sex = b.sex; for (i=0; i<2; i++) a.score[i] = b.score[i]; return a; } main() { STU c={"Qian", T, 95.0, 92.0}, d; d=f(c); printf("%s,%c,%2.0f,%2.0f\n", d.name, sex, score[O], d.score[1]); } 程序的运行结果是A.Qian, f,95,92B.Qian,m,85,90C.Zhao,m,85,90D.Zhao,f,95,92

考题 下列程序的运行结果为【】。 include include {int a; char b[10]; double c;}; 下列程序的运行结果为【 】。include<stdio.h>include<string.h>{ int a; char b[10]; double c; };void f (struct A *t);main(){ struct A a={1001,"ZhangDa",1098.0};f(a) ; printf("%d,%s,%6.lf\n",a.a,a.b,a.C);}void f(struct A*t){ strcpy(t->b, "ChangRong");}

考题 有以下程序:include include main( ) {char a[ 7 ] = "a0 \0a0 \0";int i, 有以下程序:#include <stdio.h>#include <string.h>main( ) { char a[ 7 ] = "a0 \0a0 \0"; int i,j; i = sizeof(a); j = strlen(a); printf(" % d %d \n" ,i,j); }程序运行后的输出结果是( )。A.22B.76C.72D.62

考题 设有下列程序: include include main() { int i; char si 10],ti 10]; gets( 设有下列程序:include<stdio.h>include<string.h>main(){ int i;char si 10],ti 10];gets(t);for(i=0;i<2;i++){ gets(s);if(strcmp(t,s)<0)strcpy(t,s);}printf("%s\n",t);}程序运行后,从键盘上输入(<CR>代表回车符):CDEF<CR>BADEF<CR>QTHRG<CR>,则程序的输出结果是______。

考题 以下程序的输出结果是【 】。includeincludechar*fun(char*0{ char *p--t;retur 以下程序的输出结果是【 】。include <stdio.h>include <string.h>char *fun(char *0{ char *p--t;return (p+strlen(t)/2);}main(){ char *str="abcdefgh";str=ftm(str);puts(str);}

考题 以下程序的输出结果是()。includeinclude main(){char str[12]={'s','t','r 以下程序的输出结果是( )。 #include <stdio.h> #include <string.h> main() { char str[12]={'s','t','r','i','n','g'}; printf("%d\n",strlen(str) ); }A.6B.7C.11D.12

考题 有以下程序 include main() { char a=4; printf("%d/n,a=a 有以下程序 #include <stdio.h> main() { char a=4; printf("%d/n,a=a<<1); } 程序的运行结果是______。A.40B.16C.8D.4

考题 下列程序的输出结果是( )。 include include"string.h" void main() {char a[]="He 下列程序的输出结果是( )。 #include<iostream.h> #include"string.h" void main() {char a[]="Hello Test",b[]="Test"; strcpy(a,b); cout<<a<<end1; }A.HelloB.TestC.Hello TestD.Hello Test HelloTest

考题 以下程序:includeincludemain(){char str[]="abcd\n\123\xab";printf("%d" 以下程序: #include<stdio.h> #include<string.h> main() {char str[]="abcd\n\123\xab"; printf("%d",(str)); } 运行后的输出结果是( )。A.10B.9C.7D.14

考题 下列程序的输出结果是()。includeincludemain(){char a[]="\n123\\";printf 下列程序的输出结果是( )。 #include<stdio.h> #include<string.h> main() { char a[]="\n123\\"; printf("%d,%d\n",strlen(a),sizeof(a)); }A.5,6B.5,5C.6,6D.6,5

考题 下面程序的运行结果是 ( ) include include main( ) { char * a=" 下面程序的运行结果是 ( ) # include<stdio.h> # include<string.h> main( ) { char * a="AbcdEf",* b="aBcD" a + +;b + +; printf("%d\n",strcmp(a,b)); }A.0B.负数C.正数D.无确定值

考题 下列程序的输出结果是()。 include include main() {char a[]="\n123\\";pr 下列程序的输出结果是( )。 #include<stdio.h> #include<string.h> main() { char a[]="\n123\\"; printf ("%d,%d\n",strlen(a),sizeof(a)); }A.5,6B.5,5C.6,6D.6,5

考题 有以下程序: include include void f(char * s,char*t){char k; k=*s;*s=* 有以下程序: #include <stdio.h>#include <string.h>void f(char * s,char*t){ char k; k=*s; *s=*t; *t=k; s++; t--; if( * s) f(s,t);}main( ){ char str[10] :"abedefg", * p; p = str + strlen(str)/2+1; f(p,p -2); printf( "% s \n" ,str);程序运行后的输出结果是( )。A.abcdefgB.gfedcbaC.gbcdefaD.abedcfg

考题 有以下程序 include include typedef stmct{ char name[9];char sex;flo 有以下程序#include <stdio.h>#include <string.h>typedef stmct{ char name[9];char sex;float score[2];}STU;void f(STU a){ STU b={"Zhao",'m',85.0,90.0}; int i;strcpy(a.name,b.name) ;a.sex=b.sex;for(i=0;i<2;i++) a.score[i]=b.score[i];main( ){ STU c={"Qian",'f',95.0,92.0};f(c);printf("%s,%c,%2.0f,%2.0f\n",c.name,c.sex,c.score[0],c.score[1]) ;}程序的运行结果是A.Qian,f,95,92B.Qian,m,85,90C.Zhao,f,95,92D.Zhao,m,85,90

考题 以下程序 include include main() { char*p1="abc",*p2="ABC",str[50]="xy 以下程序 #include<stdio.h> #include<string.h> main() { char*p1="abc",*p2="ABC",str[50]="xyz"; strcpy(ar+2,strcat(p1,p2)); printf("%s\n",str); } 的输出是______。A.xyzabcABCB.zabeABCC.yzabcABCD.xyabcABC

考题 有以下程序:include include main(){char *p[10]={"abc","aabdfg","dcdbe" 有以下程序: #include <stdio.h> #include <string.h> main() { char *p[10]={"abc","aabdfg","dcdbe","abbd","cd"}; printf("%d\n",strlen(p[4])); } 执行后的输出结果是( )。A.2B.3C.4D.5

考题 有以下程序:includeincludemain(){char str[][20]={"Hello","Beijing"},*P 有以下程序: #include <stdio.h> #include <string.h> main() { char str[][20]={"Hello","Beijing"},*P=str[0]; printf("%d\n",strlen(p+20)); } 程序运行后的输出结果是( )。A.0B.5C.7D.20

考题 以下程序的输出结果是【 】。includeincludechar*fun(char*t){ char *p=t;retur 以下程序的输出结果是【 】。include <stdio.h>include <string.h>char *fun(char *t){ char *p=t;return (p+strlen(t)/2);}main(){ char *str="abcdefgh";str=ftm(str);puts(str);}