学习日志 姓名:苏浩 日期:0723
|
|
今日学习任务
| 1、 熟练掌握所有关键字的使用;(static、extern、typedef) 2、 熟练掌握复合数据类型的使用;(struct、union、enum) 3、 熟练掌握宏的使用技巧;(宏的技巧及宏函数的定义) 4、 编程技巧总结 |
今日任务完成情况
(详细说明本日任务是否按计划完成,开发的代码量) |
|
今日开发中出现的问题汇总
| 刚使用关键字时,容易用错范围,导致编译错误 |
今日未解决问题
| 无 |
今日开发收获 | 了解了C语言中的关键字register, static,extern,const,typedef 的使用,掌握结构体,共用体和枚举类型的使用,还熟悉了各种判断与循环语句,if,while,switch |
自我评价
(是否按开发规范完成既定任务,需要改进的地方,与他人合作效果等)
| 通过今天的学习,将C语言的剩下的知识进行补充,对C语言有了更全面的了解,但很多方面还掌握不牢固,需要多练习,加强自己的C语言各个方面的能力 |
其他
| 无 |
#include <stdio.h>
int add(int a, int b)
{
return a + b;
}
int sub(int a, int b)
{
return a - b;
}
int mul(int a, int b)
{
return a * b;
}
int div(int a, int b)
{
return a / b;
}
int cal(int a, int b, int (*p_cal) (int, int))
{
return p_cal(a, b);
}
int main()
{
cal(5,6,add);
cal(5,6,sub);
cal(5,6,mul);
cal(5,6,div);
int (*p_cal_array[4])(int, int);
p_cal_array[0] = add;
p_cal_array[1] = sub;
p_cal_array[2] = mul;
p_cal_array[3] = div;
int i;
for(i = 0; i < 4; i++)
{
(*p_cal_array[i])(5,6);
}
int num = p_cal_array[1](5,6);
printf("result = %d\n",num);
return 0;
}
#include <stdio.h>
struct node
{
int num;
char ch;
short a;
};
typedef struct node Node;
int main()
{
Node p;
printf("sizeof(p) = %d\n",sizeof(p));
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct info
{
int num;
char ch;
char *ptr;
};
typedef struct info INFO;
int main()
{
INFO p;
p.num = 1;
p.ch = 'a';
p.ptr = (char *)malloc(sizeof(char) *100);
strcpy(p.ptr , "hello world");
printf("num = %d ch = %c\n",p.num, p.ch);
printf("ptr = %s\n",p.ptr);
}