C 测试题

来源: chenm 2022-09-24 13:02:24 [] [博客] [旧帖] [给我悄悄话] 本文已被阅读: 次 (5059 bytes)

1. Why (x=y)=z is illegal in C?

 

2. How to call C function in C++?

 

3. How to avoid multiple definition error in compiling time? in liking time?

 

4. What's generic pointer? What's generic function pointer?

 

5. What's memory leaking?

 

6. Explain the following:

(1) struct str *(*block())[8];

(2) double (*(*func)())[2][6];

 

7. Explain the following type names:

(1) int *[3]

(2) int (*)[3]

 

8. What's difference of type (signed) char and unsigned char?

 

9. What is the result in j?

short s = 0xA000;

unsigned long j;

j = (unsigned long) s;

 

10. How many keywords, how many precedences, how many operators, how many 
basic

type conversions in C?

 

11. How many name spaces in C?

 

12. Is the following code legal?

struct list { in x; struct list *list; } *list;

fun(struct list *list) {

list:

printf("%dn", list->x);

if ((list = list->list) != NULL)

goto list;

}

 

13. What's is qualified type?

 

14. Explain

int *const *const volatile *p;

 

15. Is the following code legal?

char c[] = "abc"def";

 

16. Why we need to avoid

int a;

a = (-9)/5;

 

17. Why we need to avoid the code such as:

y[i] = x[i++];

 

18. What's difference between sizeof and strlen()?

 

19. How is the unsigned number 0xaabbccdd layed out in the little endian 
computer(such as PC)?

In the big endian computer?

 

20. In the code

float *p, f[128];

p = f;

p = p + 120;

p is always pointing to f[120] independent on the machine?

 

21. In the code

int a;

a = 4 > 3;

how many is a?

 

22. In the code

while(-1) {

fun();

}

Will fun() run forever?

 

23. Is the following code legal?

struct { int x, y; } *p;

struct { int x, y; } *q;

main() { p = q; }

 

24. Is 123.4.5 a valid preprocessing number?

 

25. What's the problem with the following macro definition:

#define twice(x) (2*x)

 

26. Is the following code legal?

switch (n%4) {

while (n>0) {

case 0: *x++ = *y++; n--;

case 3: *x++ = *y++; n--;

case 2: *x++ = *y++; n--;

case 1: *x++ = *y++; n--;

}

}

 

27. In the following, which one is legal?

(1) static int x;

extern int x;

(2) extern int x;

static int x;

 

28. What's the layout for 2-D arrays in the memory?

 

29. Is the following code legal?

int b[100], p;

for (p = b; p < &b[100]; p++) *p = 0;

 

30. What's difference when reading a file using binary-mode or text-mode?

 

 

The following questions are related to compiler design:

 

31. Returning the address of a local variable is a common programming error.

Why the C compiler cannot catch such errors at compile-time?

 

32. In the following code:

int g(int, int);

int f(n) int n; {

int i = 0, j;

if (n == 1) i = 2;

while (n > 0) {

j = i + 1;

n = g(n, i);

}

return j;

}

Why do we say "whether the while loop terminates is recursively undecidable"?

 

33. What are text area, data area and bss area?

 

 

The following questions are related to the new C 1999 Standard

 

34. Explain the new keyword "restrict".

 




更多我的博客文章>>>

所有跟帖: 

这是面试题目还是学生考试题? -hot_powerz- 给 hot_powerz 发送悄悄话 hot_powerz 的博客首页 (0 bytes) () 09/27/2022 postreply 08:55:03

请您先登陆,再发跟帖!

发现Adblock插件

如要继续浏览
请支持本站 请务必在本站关闭Adblock

关闭Adblock后 请点击

请参考如何关闭Adblock

安装Adblock plus用户请点击浏览器图标
选择“Disable on www.wenxuecity.com”

安装Adblock用户请点击图标
选择“don't run on pages on this domain”