1) 下面代码的输出是什么?
#include<stdio.h>
main()
{
int x = 5;
if(x==5)
{
if(x==5) break;
printf(“Hello”);
}
printf(“Hi”);
}
A - Compile error
B - Hi
C - HelloHi
D - Hello
2) 下面代码的输出是什么?
#include<stdio.h>
main()
{
printf(“\”);
}
A - \
B - \”
C - “
D - Compile error
3) 在系统build-in库中,哪个函数可以调整动态分配地址的大小?
A - malloc
B - calloc
C - realloc
D - resize
4) 下面代码的输出是什么?
#include<stdio.h>
main()
{
printf(“%d”,-11%2);
}
A - 1
B --1
C - 5.5
D --5.5
5) 下面代码的输出是什么?
#include<stdio.h>
main()
{
int x;
float y;
y = x = 7.5;
printf(“x=%d y=%f”,x,y);
}
A - 7 7.000000
B - 7 7.500000
C - 5 7.500000
D - 5 5.000000
6) 从下列选项中,选择正确的函数执行顺序
a = f1(23, 14) * f2(12/4) + f3();
A - f1, f2, f3
B - f3, f2, f1
C - f2, f1, f3
D - 编译器不同,调用顺序也可能不同
7) 在下面语句中,pf表示什么?
int(*pf)();
A - pf是一个返回值为int的函数指针
B - pf是一个指针
C - pf是一个函数指针
D - 以上都不是
8) 在内置函数中,哪个函数可以用作正则表达式的字符串查找?
9) 有没有办法比较2个struct变量?
10) 宏定义是在什么时候被展开的?
11) 编译C语言程序时,分几个阶段?
12) #undef有什么用处?
13) XOR,是什么如何工作的?
14) 下面代码的输出是什么?
#include<stdio.h>
main()
{
union abc {
int x;
char ch;
}var;
var.ch = ‘A’;
printf(“%d”, var.x);
}
A - A
B - 垃圾值
C - 65
D - 97
15) 下面代码的输出是什么?
#include<stdio.h>
main()
{
char s[20] = “Hello\0Hi”;
printf(“%d %d”, strlen(s), sizeof(s));
}
A - 5 9
B - 7 20
C - 5 20
D - 8 20
16) 下面代码的输出是什么?
#include<stdio.h>
main()
{
char s[]=“hello”, t[]=”hello”;
if(s==t){
printf(“eqaul strings”);
}
}
A - eqaul strings
B - uneqaul strings
C - 没有输出
D - 编译错误
17) fgets()比gets()更安全是吗,为什么?
18) 下列语句有何错误?
signed int *p=(int*)maIIoc(sizeof(unsigned int));
A - 不恰当的数据类型升级
B - 运行时报错
C - 分配的内存不能存int值
D - 没有问题
19) Int类型的长度?
A - 2
B - 4
C - 8
D - 依赖于编译器
20) 下列语句的输出?
#include<stdio.h>
int main();
void main()
{
printf(“Okay”);
}
A - Okay
B - 没有输出
C - 编译错误,未定义main()函数
D - 编译错误,定义和声明不匹配
21) 下列语句的输出?
#include<stdio.h>
void swap(int m, int n)
{
int x = m;
m = n;
n = x;
}
main()
{
int x=5, y=3;
swap(x,y);
printf(“%d %d”,x,y);
}
A - 3 5
B - 5 3
C - 55
D - 编译错误
22) 下列语句的输出?
#include<stdio.h>
main()
{
int const a = 5;
a++;
printf( “%d ”,a);
}
A - 5
B - 6
C - 运行错误
D - 编译错误
23) 50的二进制表示是什么?
A - 110010
B - 1010110
C - 101
D - 101.011.00.00
24) 下列语句的输出?
#include<stdio.h>
void main()
{
char s[] = “C++”;
printf(“%s ”,s);
s++;
printf(“%s”,s);
}
A - C++ C___
B - C++ ++
C -++ ++
D - 编译错误
25) 下列语句的输出?
#include<stdio.h>
main()
{
int *p = 15;
printf(“%d”,*p);
}
A - 15
B - 垃圾值
C - 运行错误
D - 编译错误
Key
1) A
2) D
3) C
4) B
5) A
6) D
7) A
8) strstr()
9) 没有办法,只能分别比较2个struct变量的元素
10) 在预处理阶段被展开
11) 预处理,编译,汇编,链接
12) 取消定一个,一个已经定义的宏
13) 异或操作,2个对应的bit都相同,则为0,否则为1。
14) C
15) C
16) C
17) 是的,因为fgets指定了可以接收字符串的最大长度。
18)
19) D
20) D
21) B
22) D
23) A
24) D
25) C