CC++语言笔试面试题目含答案.docx
- 文档编号:23439567
- 上传时间:2023-05-17
- 格式:DOCX
- 页数:47
- 大小:43.64KB
CC++语言笔试面试题目含答案.docx
《CC++语言笔试面试题目含答案.docx》由会员分享,可在线阅读,更多相关《CC++语言笔试面试题目含答案.docx(47页珍藏版)》请在冰豆网上搜索。
CC++语言笔试面试题目含答案
C_C++§言笔试面试题目含答案
C语舌语语
_:
语语语语语
1.
voidExample(characHello[])
(
printf("%d”,sizeof(acHello));
return;
}
voidmain()
(
characHello[]="hello";
Example(acHello);
return;
}
的语出是()
A4B5C6D不定确
2.语上语语的字语序默语是大字语的〜如果主机是小字语序〜在语通信语语语语行字语序语语〜如果主机是网网
大字语序〜语了程序的一致性及可移植性〜最好也在程序中加上字语序语语的操作;空操作,。
(
)
A.正确B.语语
3.int*(*ptr)();
语以下述中正的是叙确()
A)ptr是指向一语语的指语语量数
B)ptr是指向int型据的指语语量数
C)ptr是指向函的指语数,语函返回一数个int型据数
D)ptr是指向函的指语数,语函的返回语是指向数int型据的指语数4.此函语语把数32位IP地址(语序网)以字符申的方式打印出,来char
*IpAddr2Str(unsignedlongulIpAddr)
(
charszIpAddr[32];
unsignedlongulLocIpAddr=ntohl(ulIpAddr);//把语序语语语主机序网
(void)VOS_sprintf(szIpAddr,"%d.%d.%d.%d",ulLocIpAddr>>24,
(ulLocIpAddr>>16)&Oxff,(ulLocIpAddr>>8)&Oxff,ulLocIpAddr&
Oxff);
returnszIpAddr;
}
下面描述正的是;,,确
A、语数szIpAddr空语不语〜
B、函返回局部语数数szIpAddr语量地址〜
C、语出的IP地址次序语倒〜
5.
#defineOK0#defineERR1#defineERROR(-1)#defineBUFFER_SIZE
256char*GetMemory(unsignedlongulSize)
char*pcBuf=NULL;
pcBuf=(char*)malloc(ulSize);
if(NULL==pcBuf)
{
returnERROR;
}
returnpcBuf;
}
voidTest(void)
{
char*pszBuf=NULL;
pszBuf=GetMemory(BUFFER_SIZE);
if(NULL!
=pszBuf)
{
strcpy(pszBuf,"HelloWorld!
\r\n");
printf(pszBuf);
free(pszBuf);
}
return;
}
如下描述正的是,确
A、pszBuf指向的存不能超语内255
B、GetMemory函的常分支返回了数异-1〜是一非法地址个GGetMemory^常
分支有语放空语〜异没
DkpcBuf语局部指语〜指向的存在内将GetMemory^语用后语放
6、#include"stdio.h"unsignedshort*Sum(unsignedchara,unsignedcharb)
{
unsignedshorts=0;
s=a+b;
return&s;
}
intmain()
{
unsignedshort*p=NULL;
unsignedchara=1,b=2;
p=Sum(a,b);
printf("%u+%u",a,b);
printf("=%u\n",*p);
return0;
}
程序语行语果是;,
A.1+2=0B.1+2=3C.1+2=NULLD.不可语语7、语有如下定语:
BOOLgStatusA=FALSE;BOOLgStatusB=TRUE;intgVarA=100;
intgVarB=100;
语语行main函后数gVarA和gVarB的语分语语()
BOOLCheckA()
{
if(gStatusA)
(
gVarA++;
}
else
(
gVarA--;
}
returngStatusA;}
BOOLCheckB()
(
if(gStatusB)
(
gVarB++;
}
else
(
gVarB--;
}
returngStatusB;}
intmain(intargc,char*argv[])
(
if(CheckA()&&CheckB())
(
printf(“StatusOK”);
}
return0;
}
A,99和100B,99和101C99和99D101和998.下面的代语中〜函数Test语行完语后〜希望语出无符语整型的号1。
voidVarInit(unsignedchar*pucArg)
{
*pucArg=1;
return;
}
voidTest()
{
unsignedlongulGlobal;
VarInit(&ulGlobal);
printf("%lu",ulGlobal);
return;
}
下面描述正的是,;,确
A.语VarInit()函语语的语型语语数参数
B.printf;,语出格式语语
C.语语VarInit()中参数pucArg的语语空指语9、
voidAddFunc(unsignedinta,unsignedintb,unsignedint*c)
{
*c=a+b
}
voidmain(void)
(
unsignedchare=200;
unsignedcharf=100;
unsignedcharg=0;
AddFunc((unsignedint)e,(unsignedint)f,(unsignedint*)&g);
printf("%d",g);
}
下面语法正的是;,,确
A语g语行语型语语语致函语用语存越界〜数写内
B语e、f语行语型语语语致函语用语存越界〜数写内
C函语用语不能改语数g的语。
10、voidmain(void)
(
unsignedchara=200;
unsignedcharb=100;
unsignedcharc=0;
c=a+b;
printf("%d%d",a+b,c);}
下列程序的语行语果语()
A300300
B4444
C30044
D44300
11、在X86〜VC++6.0语境下〜有下列程序#include
intmain()
{
charcA;
unsignedcharucB;
unsignedshortusC;
cA=128;
ucB=128;
usC=cA+ucB;
printf("0x%x",usC);
usC=cA+(short)ucB;
printf("0x%x",usC);
usC=(unsignedchar)cA+ucB;
printf("0x%x",usC);
usC=cA+(char)ucB;
printf("0x%x",usC);
return0;
}
语出语果是()
A)0x00x00x1000xff00
B)0x00x1000x1000xff00
C)0x00x1000x1000x0
D)0x00x00x1000x012.switch(c)中的c的据语型可以是数char、long、float、unsigned、bool.()
A.正确B.语语
13.voidExample()
{
inti;
characNew[20];
for(i=0;i<10;i++)
{
acNew[i]='0';
}
printf("%d\n",strlen(acNew));
return;
}
的语出语()
A0B10C11D不定确
14.如下程序用于把"blue"字符申返回,
char*GetBlue(void)
{
char*pcColor;
char*pcNewColor;
pcColor="blue";
pcNewColor=(char*)malloc(strlen(pcColor));
if(NULL==pcNewColor)
(
returnNULL;
}
strcpy(pcNewColor,pcColor);
returnpcNewColor;
}
下面描述正的是,确
A、字符申“blue”存放在语〜内
B、函数GetBlue返回局部语量地址〜
C、存空语分配语度不语〜内strcpy函拷语越界〜数
15.语出以下定语:
characX[]="abcdefg";
characY[]={'a','b','c','d','e','f,'g'};
语正的述语确叙()
A)语数acX和语数acY等价B)语数acX和语数acY的语度相同
C)语数acX的语度大于语数acY的语度D)语数acX的语度小于语数Y的语度16.有以下程序段
characArr[]="ABCDE";
char*pcPtr;
for(pcPtr=acArr;pcPtr { printf("%s\n",pcPtr); } return; 语出语果是() A)ABCDB)AC)ED)ABCDE BDBCDE CCCDE DBDE EAE 17.voidExample() ( inti; characNew[20]=(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0}; for(i=0;i<10;i++) ( acNew[i]='0'; } printf("%d\n",strlen(acNew)); return; } 的语出语,() A0B10C11D不定确 18.如下程序用于把"blue"字符申打印出,来 voidPrintBlue() ( charpcBlue[]=('b','l','u','e'}; printf("%s",pcBlue); return; } 下面描述正的是;,,确 A、pcBlue语初始化语有字符申语束符〜数没 B、语数pcBlue定语语必语指明语度〜 19.如下代语语语中〜FuncA语每毫秒定语语行的函〜在语函中〜需要语语每数 数TIME_INTERVA廛秒语行一次DO_Something()的操作。 语指出段代语中的语语, #defineULONGunsignedlong #defineTIME_INTERVAL200 voidDoSomething(void) { /*....*/ return; } voidFuncA() { staticULONGulPreCall=0; ULONGulNowInMsHigh=0; ULONGulNowInMsLow=0; (VOID)VOS_Tm_Now(&ulNowInMsHigh,&ulNowInMsLow);/*语取前的语语当,以毫秒语语位〜用64bits表示〜ulNowInMsHigh语高32位,ulNowInMsLow语低32位*/ if((0==ulPreCall)||(ulNowInMsLow>=(ulPreCall+ TIME_INTERVAL))) { ulPreCall=ulNowInMsLow; } else { return; } DoSomething(); return; } A、函数FUNC_第一次被语用语〜不语行Do_Something()操作〜B、函数 FUNCR能在一段语语后失效〜因语ulNowInMsLow^出语〜翻 C、ulPreCall不语语定语语语语量〜静 20、 #defineNULL0 #defineMEM_OK0 #defineMEM_ERR1 enumENUM_STAT_ITEM { STAT_ITEM0, STAT_ITEM1, STAT_ITEM_BUTT }; typedefstructtag_PERM_COUNT_STAT_INFO( unsignedshortstat_item; unsignedshortnumber; }_SPermCountStatInfo; _SPermCountStatInfopcsi[STAT_ITEM_BUTT]=( (STAT_ITEM0,16000}, (STAT_ITEM1,50000},} unsignedlong*pulStatDataBuffer=NULL;unsignedshort AllocPermMemory(void){ unsignedshortusBufferSize=0; unsignedshortusLoop=0; for(usLoop=0;usLoop { usBufferSize+=pcsi[usLoop].number; } pulStatDataBuffer=(unsignedlong*)malloc(sizeof(unsignedlong)*usBufferSize); if(NULL==pulStatDataBuffer) { returnMEM_ERR; } returnMEM_OK; } 下面语法正的是;,,确 Aunsignedshort语型不能表示循语中体将16000与50000相加的和66000 B语数pcsi的number域是unsignedshort语型〜不能表示50000语语大的 字数C循语件语语改语条usLoop<=STAT_ITEM_BUTT2ig指出下面语段代语中的语语, unsignedlongFuncB(unsignedlongulCount) { unsignedlongulSum=0; while(0<=ulCount) { ulSum+=ulCount; ulCount--; } returnulSum; } voidtest(void) { unsignedlongulTotal=0; ulTotal=FuncB(10); printf("%lu",ulTotal);} 下面描述正的是确(), A、while循语判始语语〜断真 B、test打印语出55〜 C、循语在语行体内2的32次方后〜ulSum语始溢出语〜翻 22.语指出下面程序的语语 voidTest(void) ( char*szStr=(char*)malloc(100); if(NULL==szStr) ( return; } strcpy(szStr,"hello"); free(szStr); if(NULL! =szStr) ( strcpy(szStr,"world"); printf("%s",szStr); } return; } 下面描述正的是;,确 A、strcpy有语尾符拷语到没将szStr中 B、语语放空语的指语语行拷语操作 C、szStr被free后〜szStr语空。 即 23.#defineBUFFER_SIZE256voidGetMemory(char**ppszBuf) ( if(NULL==ppszBuf) ( ASSERT(0); return; } *ppszBuf=(char*)malloc(BUFFER_SIZE); return; } voidTest(void) ( char*pszBuf=NULL; GetMemory(&pszBuf); strcpy(pszBuf,"helloworld\r\n"); printf("%s",pszBuf); free(pszBuf); return; } 下面语法正的是;,,确 A、pszBuf的语永语语NULL^ B、malloc存后有判是否成功〜内没断 C、strcpy拷语越界〜 DKGetMemory无法申语的存地址语语语将内pszBuf〜 24、语语下面函中数1、2、3语语入什语语句才合理,;,填 A、不添,不添〜不添 B、free(pMsg);,free(ptmpMsg);,不添C、free(pMsg);,free(ptmpMsg);,free(ptmpMsg); D不添,free(pMsg);,free(ptmpMsg);E、 free(pMsg);,free(pMsg);,free(ptmpMsg); F、不添,不添,free(ptmpMsg); #defineCOMM_MSG_LEN100 char*GetMessageBuffer(intmalloc_len)( char*ptr=NULL; ptr=(char*)malloc(malloc_len) returnptr; } intFuncTest(void) ( intmalloc_len=COMM_MSG_LEN; char*pMsg=NULL; char*ptmpMsg=NULL; pMsg=GetMessageBuffer(malloc_len); if(NULL==pMsg) ( 1___ returnERROR; } fillMessage(pMsg); sendMessage(pMsg); ptmpMsg=GetMessageBuffer(malloc_len); if(NULL==ptmpMsg) { 2___ returnERROR; } FillMessage(ptmpMsg); SendMessage(ptmpMsg); free(pMsg); 3___ returnOK; } 25.以下述中不正的是叙确() A)在不同的函中可以使用相同名字的语量数 B)函中的形式是在语中保存数参数 C)在一函定语的语量只在本函范语有效个数内数内 D)在一函的语合语句中定语的语量在本函范语有效个数内数内(语合语句指函 中的成语括成数号构的代语) 26.全局语量可以定语在被多个.C文件包含着的语文件中。 () A.正确B.语语 27.在函部定语的语量数内(语语量、寄存器语量等特殊语量静除外)的存是在语存中〜内内所以在定语函数内内部的语量的语候〜一定要保语语不能语溢出。 如果语语语量占用空语语大〜语语使用存申语的方式〜语语语语量指向的存内内就是在堆存中了。 () A.正确B.语语 28.局部语量可以和全局语量重名〜语语的语候不出语语语〜会但一旦不小心〜就可能语致使用语语语量〜所以在定语局部语量的语候〜不要和全局语量重名C() A.正确B.语语 29.语有如下定语: unsignedlongpulArray[]=(6,7,8,9,10}; unsignedlong*pulPtr; 语下列程序段的语出语果语() pulPtr=pulArray; *(pulPtr+2)+=2; printf("%d,%d\n",*pulPtr,*(pulPtr+2)); A)8,10B)6,8C)7,9D)6,10 30.structstu ( intnum; charname[10]; intage; }; voidFun(structstu*p) ( printf("%s\n",(*p).name); return; voidmain() ( structstustudents[3]={{9801,"Zhang",20}, {9802,"Wang",19}, {9803,"Zhao",18}}; Fun(students+2); return; } 语出语果是() A)ZhangB)ZhaoC)WangD)18 31.以下程序行后运,语出语果是() voidmain() { char*szStr="abcde"; szStr+=2; printf("%lu\n",szStr); return; } AcdeB字符c的ASCLL®语 C"abcde"语常申中字符个c所在的地址D出语32.语有以下宏定语: #defineN3 #defineY(n)((N+1)*n)/*语语定语在语程语范中是不允语的〜如果在语语 中语语用了你〜 语自打手心三下*/ 语语行语句: z=2*(N+Y(5+1));后,z的语语() A)出语B)42C)48D)54 33、有如下宏定语和语定语构 #defineMAX_SIZEA+B struct_Record_Struct { unsignedcharEnv_Alarm_ID: 4; unsignedcharpara1: 2; unsignedcharstate; unsignedcharavail: 1; }*Env_Alarm_Record; pointer=(struct_Record_Struct*)malloc( sizeof(struct_Record_Struct)*MAX_SIZE); 当A=2,B=3语pointer分配()字语的空语。 个注意,机器是按照4字语语语 A)20B)15C)11D)934、语语下面语目中a,b,c语出语语多少,;, A、10,210,30 B、100,210,300 C、110,210,310 »100,210,30 E、110,200,30 #include #defineFUNC(A)A++;\ A*=10;intmain(intargc,char*argv[]){ inta=10; intb=20; intc=30; if(a>10) FUNC(a); if(b>=20) FUNC(b); if(
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- CC 语言 笔试 面试 题目 答案