[单选题]

有以下程序 #include 〈string.h〉 main ( ) { char p[]={'a','b ,'c'}, q[10]={'a','b','c'}; printf("%d %d/n",strlen(p),strlen(q)); } 以下叙述中正确的是

A.在给p和q数组置初值时,系统会自动添加字符串结束符,故输出的长度都为3

B.由于p数组中没有字符申结束符,长度不能确定;但q数组中字符串长度为3

C.由于q数组中没有字符串结束符,长度不能确定:但p数组中字符串长度为3

D.由于p和q数组中都没有字符串结束符,故长度都不能确定

参考答案与解析:

相关试题

有以下程序 #include<stdio.h>#include<string.h

[单选题]有以下程序#include <stdio.h>#include <string.h>void fun(char s[][10],int n){char t; int i,j;for(i=0;i<n-1;i++)for(j=i+1;j<n;j++)/*比较字符串的首字符大小 ,并交换字符串的首字符*/if(s[i][0]<s[j][0]) {t=s[i][0];s[i][0]=s[j][0];s[j][0]=t;}}main(){char ss[5][10

  • 查看答案
  • 有以下程序 #include<stdio.h>#include<string.h

    [单选题]有以下程序#include<stdio.h>#include<string.h>typedef struct {char name[9]; char sex; float score[2];}STU;STU f(STUA.{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=b.score;return a;}main(){STU

  • 查看答案
  • 有下面程序段#include"stdio.h"#include"string.h

    [单选题]有下面程序段 #include"stdio.h" #include"string.h" main() { char a[3][20]={{"china"},{"isa"},{"bigcountry!"}}; chark[100]={0},*p=k; int i; for(i=0;i<3;i++) {p=strcat(p,a[i]);} i=strlen(p); printf("%d/n","i);} 则程序段的输出结果是A.18B.19C.20D.21

  • 查看答案
  • 有以下程序 # include <string.h> main() {char

    [单选题]有以下程序# include <string.h>main(){char p[20]={′a′, ′b′, ′c′, ′d′}, q[]="abc", r[]="abcde";strcat(p, r); strcpy(p+strlen(q), q);printf("%d/n",strlen(p));}程序运行后的输出结果是A.9B.6C.11D.7

  • 查看答案
  • 有以下程序 # include <string.h> main() {char

    [单选题]有以下程序# include <string.h>main(){char p[20]={′a′, ′b′, ′c′, ′d′}, q[]="abc", r[]="abcde";strcat(p, r); strcpy(p+strlen(q), q);printf("%d/n",strlen(p));}程序运行后的输出结果是A.9B.6C.11D.7

  • 查看答案
  • 有以下程序#include <string.h>main( int argc,

    [单选题]有以下程序#include <string.h>main( int argc, char *argv[ ]){ int i=1,n=0;while (i< argc) {n=n+strIen ( angv[i ] ) ;i++; }printf("%d/n",n);}该程序生成的可执行文件名为: proc.exe 。若运行时输入命令行:proc 123 45 67则程序的输出结果是A.)3B.)5C.)7D.)11

  • 查看答案
  • 有以下程序#include <string.h>main( ){ char p[

    [单选题]有以下程序#include <string.h>main( ){ char p[20]={ 'a', 'b', 'c', 'd'},q[]="abc", r[]="abcde"strcat(p,r); s trcpy(p+strlen(q),q);p rintf("%d/n", strlen (p));}程序运行后的输出结果是A.)9B.)6C.)11D.)7

  • 查看答案
  • 有以下程序#include <string.h>main( ){ char p[

    [单选题]有以下程序#include <string.h>main( ){ char p[20]={'a','b','c','d'},q[]="abc", r[]="abcde";strcpy(p+strlen(q),r); strcat(p,q);printf("%d%d/n",sizeof(p),strlen(p));}程序运行后的输出结果是A.)20 9B.)9 9C.)20 11D.)11 11

  • 查看答案
  • 有以下程序 #include <string.h>main(){ FILE *f

    [单选题]有以下程序 #include <string.h>main(){ FILE *fp; int i,k,n; fp=fopen("data.dat", "w+"); for(i=4; i<9; i++) { fprintf(fp,"%d",i); if(i%3==0) fprintf(fp,"/n"); } rewind(fp); fscanf(fp,"%d%d",&k,&n); printf("%d %d/n",k,n); fclose(

  • 查看答案
  • 有以下程序 #include<string.h> main() {char p[

    [单选题]有以下程序#include<string.h>main(){ char p[]={′a′, ′b′, ′c′},q[10]={ ′a′, ′b′, ′c′};printf("%d%d/n",strlen(p),strlen(q));}以下叙述中正确的是A.在给p和q数组置初值时,系统会自动添加字符串结束符,故输出的长度都为3B.由于p数组中没有字符串结束符,长度不能确定,但q数组中字符串长度为3C.由于q数组中没有字符串结束符,长度不能确定,但p数组中字符串长度为3D.由于p和q

  • 查看答案
  • 有以下程序#include 〈string.h〉 main ( ){charp[