c语言常见笔试题总结
《c语言常见笔试题总结》由会员分享,可在线阅读,更多相关《c语言常见笔试题总结(3页珍藏版)》请在装配图网上搜索。
1、读书破万卷下笔如有神【1使用宏】1.1#ifdef NDEBUG#define TRACE(S) S#else#define TRACE(S) printf( %s;n ,#S); S#endif问:以上TRACE()宏的作用是什么?1.2 #error 的作用?1.3 定义一个宏,求出给定数组中的元素的个数#define NELEMENTS(array) ?1.4 定义一个宏,求出给定结构中给定成员的偏移量#define OFFSET(structure, member) ?【2数据声明和定义】给定以下类型的变量a的定义式:a) An integerb) A pointer to an in
2、tegerc) A pointer to a pointer to an integerd) An array of 10 integerse) An array of 10 pointers to integersf) A pointer to an array of 10 integersg) A pointer to a function that takes an integer as an argument and returns an integerh) An array of ten pointers to function s that take an integer argu
3、ment and return an integer 【3复杂类型(1)】有如下表达式:char (*(*x()口)();请用文字描述x是什么。【4复杂类型(2)】jmp_buf的定义: typedef struct _jmp_buf REG_SET reg;int extra3; jmp_buf1;setjmp函数的原型:extern int setjmp (jmp_buf _env);问:调用setjmp时传递env的内容,还是传递指针? 【5头文件】问:为什么标准头文件都有类似以下的结构?#ifndef _INCvxWorksh#define _INCvxWorksh#ifdef _cp
4、lusplus extern C” #endif/*.*/#ifdef _cplusplus#endif#endif /* _INCvxWorksh */【6 static关键字】请说出static关键字的3种用处:(1)用于全局变量;(2)用于局部变量;(3)用于函数。/* file.c */static int a;int b;static int fn()static int x;int y;【7 const关键字】7.1 const关键字的意义是什么?7.2 解释以下的变量定义:const int a1;int const a2;const int *a3;int * const a4
5、;int const * const a5;【8 volatile关键字】8.1 volatile意义?例如volatile int *p;8.2 volatile能和const 一起使用吗?例如 volatile const int *p;【9 sizeof()】有以下定义:char *pmsg =A;char msg口 = A”;char ch = A;问:sizeof(pmsg) = ?sizeof(msg) = ?sizeof( A) = ?sizeof(ch) = ?sizeof( A) = ?(在C+中等于多少?) void f(char param100)/ sizeof(par
6、am) = ?【10字符串】有以下代码char *pmsg = hello, world!”;strcpy(pmsg, hi, there.);试评论该代码。【11混合运算】有以下代码:void foo()unsigned int a = 6;int b = -20;(a+b 6) ? puts( 6) : puts( = 6 );请问调用foo()的输出?【12内存访问】有以下代码:void fn()int a100;int *p;p = (int *)(unsigned int)a + 1);printf( p=0x%xn ”, *p);试评论以上代码。【13 C库函数】请说明以下函数的意义:void perror(const char *_s);fdprintf(int, const char *,);isspace(), isxdigit(), strerr(), sprintf()
- 温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。