C语言钻石段位测试题
满分100分的测试题,你能做多少分?答案见链接https://blog.csdn.net/qq_23274715/article/details/106302128。
-
常数
123ul
,123.45l
中的ul
、l
代表什么含义?(2分) -
C语言中,数值16用十六进制表示为
0x10
,哪用二进制如何表示?(2分) -
举例谈谈
#define Mul(x,y) x*y
这个带参宏的缺点?(2分) -
谈谈
#undef
预处理命令的应用。(2分) -
谈谈
#if
,#ifdef
,#ifndef
的使用区别。(2分) -
如果编译时,不满足某些条件,用户如何向编译器抛出警告或者错误。(2分)
-
谈谈函数指针的用途?(5分)
-
谈谈弱函数的用途?(5分)
-
volatile
关键字的行为发生在哪个阶段?(编译还是运行?).(5分) -
从函数、变量、作用范围角度谈谈
static
,extern
.(5分) -
什么是可重入函数,什么是不可重入函数?(5分)
-
编写一个判断处理器为大端还是小端的函数(大端返回1,小端返回0)。(3分)
-
编写一个给二维数组
uint8_t data[4][8]
分配内存的函数。(5分) -
编写一个变参函数,实现类似
printf()
功能。(5分) -
编写一个变参调试宏
debug()
。可以完成下面的打印控制。(5分)//可以通过宏控制是否有打印输出 #define MY_DEBUG_ENABLE 1 void main(void){ debug(MY_DEBUG_ENABLE,"hello word\n"); debug(MY_DEBUG_ENABLE,"%d\n",1); }
-
下面的这段程序,打印结果是什么?(5分)
void main(void) { int32_t a = -10; uint32_t b = 5; if(a > b){ printf("a>b\n"); } else{ printf("a<=b\n"); } }
-
在
32bit
的小端
处理器上,下面的两个结构体各占多大内存,请画出内存分布图。(5分)struct Base1{ int a1; long a2; char a3; }; struct Base2{ int a1; struct Base1 a2; char a3; };
-
下面两个函数中使用
const
有何好处。(5分)int Sum(const int *pBuff,int num){ } void Test(void){ const uint8_t IdOffset = 16; }
-
下面程序函数WaitThread()中的循环能跳出吗?为什么?(5分)
char DataReg; /* 等待线程 */ void WaitThread(void) { DataReg = 1; while(DataReg){ } } /* 其他线程 */ void OtherThread(void) { DataReg = 0; }
-
下面程序中
***p5
中的内容是什么?(5分)void main(void) { /* []中的值为地址中的内容,如 0x0000 [10] 为地址 0x0000中的内容10 */ int a = 10; //分配地址 0x0000 [10] int *p1 = &a; //分配地址 0x0004 [0x0000] int **p2 = &p1; //分配地址 0x0008 [0x0004] int ***p3 = &p2; //分配地址 0x000c [0x0008] int ****p4 = &p3; //分配地址 0x0010 [0x000c] int *****p5 = &p4; //分配地址 0x0014 [0x0010]
-
分析下面程序的打印结果。(5分)
#define TO_STRING(str) #str #define TO_CONNECT(arg1,arg2) arg1##arg2 #define TO_CONNECT_STRING(arg1,arg2) TO_STRING(arg1##arg2) void main(void) { char *pstr = TO_STRING(guoweilkd); char *pstr1 = TO_STRING("guoweilkd"); int value = TO_CONNECT(1,2); printf("%s,%s,%d\n",pstr,pstr1,value); char *pstr2 = TO_CONNECT_STRING(guoweilkd,123); printf("%s\n",pstr2); }
-
在下面程序中使用
spritf()
函数将一个浮点数转换为字符串.其中浮点数的小数位由输入参数决定。(5分)char *GetfloatStr(char *pBuff,float value,int nbit){ //user code }
-
下面程序的
__attribute__
属性有什么作用。(5分)static int b __attribute__((section(".endaddr"))); uint32_t __attribute__((section(".endaddr"))) ProgramEndAddr(void) { return (uint32_t) ProgramEndAddr; }
关于技术交流
此处后的文字已经和题目内容无关,可以不看。
qq群:825695030
微信公众号:嵌入式的日常
如果上面的文章对你有用,欢迎打赏、点赞、评论。