第一题:
不使用任何库,编写一个函数char*remove(const char* src,char c ),参数src为输入的字符串,长度不确定,不为空。参数c为任何可能的字符返回值。Src中删除了所有字符c的字符串。对是否通过动态分配内存的方式返回这个字符串还是使用静态的内存不做限制。
第二题:
如下这段代码是否有错误,如果有,请找出错在哪里写出原因并改正
Voidf( )
{
Charstr[6]=”12345”,
Constchar*p1=str,
Char *constp2=str
P1[0]=’6’
P2{0}=’7’
P1=NULL
P2=NULL
}
第三题:
调用函数Function2之后,x, y, z三个变量的值是什么?
VoidFunction2(int x,int& y, int* z)
{
X=1;
Y=2
*z=3;
Return;
}
Intx,y,z=0
Function2(x, y, &z);
第四题:
正则表达式 .*\*123\d能与以下哪些选项匹配? CD
A.******123
B.*****_1234
C.******1234
D._*1234
E._*12
3写出下面的生活场景可以用那种数据结构描述
(1) 汽车进出加油站加油。(2)货车装货、卸货。____
第六题:
在32位操作系统中A占__ 字节,B占____字节
structA
{
inta;
int*b
charc;
}
union B
{
inta ;
charb;
char * c;
};
阅读下面的C/C++源代码,请指出哪些代码是错误的或有风险,如果有,请指出错误是什么? const int * foo1()
{
int a = 10;
return &a;
}
const int * foo2()
{
int a = new int(10);
return a;
}
const int * foo3()
{
static int a = 10;
return &a;
}
int main (int artc,char* argv[])
{
const int *p1=foo1();
const int *p2=foo2();
const int *p3=foo3();
return 0;
}
第八题:
调用函数Founction2之后,x,y,z三个变量的值是什么?
void Function2(int x,int &y,int *z)
{
X = 1;
y = 2;
*z=3;
Return ;
}
int x,y,z=0;
Function2(x,y,&z);
(必知必会)在32位X86平台,下述代码段输出结果是? unsigned int i=1;
unsigned int j=2;
printf(“0x%08x\n”,i,j);
if (i – j >0){
Printf(“%d>%d”,i,j);
}else{
printf(“%d
}
输出为:,
第九题:
请指出以下程序中的错误
Void test1()
{
char string [11];
char *str1=”Sinfor test”;
strcpy(string,str1);
}
第十题:
有数组定义int a[2][2]={{1},{2,3}};则a[0][1]的值为__A__
A0;B1;C2;D3;
设有以下定义
Int a=0double b=1.25char c=’a’#define d 2 则下面语句中错误的是____
Aa++Bb++Cc++Dd++
第十一题:
请问运行TEST函数会有什么样的结果
Void test(void)
{
Char*str=(char*)malloc(100);
Strcpy(str,”hello”);
Free(str);
If(str!=NULL)
{
Strcpy(str,”world”);
Printf(str);
}
}