1. BOOL和bool区别
2. 谈谈对回调函数的理解
3. 在。。。编码中汉字占几个字节
如何用c语言编程求对数:如:log(2)16 (括号中数为底数)
使用换底公式:log(a)b=log(s)b/log(s)a
- #include <math.h>
- #include <stdio.h>
- int main(void)
- {
- double result;
- double x=16;
- result=log(16)/log(2);
- printf("result is %lf\n",result);
- }
结构体相关
- #include <stdio.h>
- #include <stdlib.h>
- struct ss
- {
- int aa;
- int bb;
- };
- int main(void)
- {
- int i[]={9,8,7,6,5,4,3,2,1,0};
- struct ss *p1=(struct ss*)i;
- struct ss *p2=p1+4;//pp每加1,相当于加了sizeof(ss)个字节
- printf("%d %d\n",p2->aa,p2->bb); //1 0
- }
填充函数,使输出为:ood
- #include <stdio.h>
- #include <stdlib.h>
- void move(__A__)
- {
- ______B______
- }
- int main(void)
- {
- char *str="good";
- move(__C__);
- printf("%s\n",str); //使输出为:ood
- return 0;
- }
答案:考察传值与传址。str其实也是个变量,若要改变它的指向,则要改变它的值,所以实参需传入它的地址。
- #include <stdio.h>
- #include <stdlib.h>
- void move(char **s)
- {
- *s+=1;
- }
- int main(void)
- {
- char *str="good";
- move(&str);
- printf("%s\n",str);
- return 0;
- }