|
|
今日学习任务
|
嵌入式C语言开发实战
|
今日任务完成情况
| 今日任务按计划完成 1.熟练掌握指针的定义与使用;(对应内存空间与指向内存空间) 2.掌握指针运算符的有关知识(指针的字节长度、存储区域、作用域) 3.指针的操作(*、&)以及熟练掌握多维指针的使用;(n 维指针) 4.熟练掌握野指针及如何防止野指针;(消灭野指针) 5.while 和for 语句copy的区别和编写 6.熟练掌握函数的作用;函数的语法以及程序的框架
|
今日开发中出现的问题汇总
| 1.在写拷贝程序时,在for循环中,*(s + i) = *(p + i);*(s + i) = ‘\0’;而在while循环中,*s = * p; s++; p++;*s = ‘\0’;二者混用了 |
今日未解决问题
| 无 |
今日开发收获 |
4.熟练掌握野指针及如何防止野指针;(消灭野指针)(要养成良好的编码习惯) 5.while 和for 语句copy的区别和编写 6.熟练掌握函数的作用;函数的语法以及程序的框架(先在main函数中写好函数的调用,再根据main函数的返回值需要编写子函数,确定子函数的返回类型) |
自我评价
| 今天基本能够跟上老师的教学进程,自己在写代码时有些卡顿,逻辑不是很清晰,听完老师的讲解后,理清了逻辑,在自己课后整理后,可以自己写出来 |
其他
| 无 |
1.从一个字符串中获取数字的最大长度,并将其输出
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_LEN sizeof (char) * 10000
int main()
{
int i;
int len = 0;
int max = 0;
char *p = (char *) malloc (MAX_LEN);
char *s = (char *) malloc (MAX_LEN);
char *temp = p;
char *s_temp = s;
if(p == NULL || s == NULL)
{
printf("malloc error!\n");
exit(1);
}
memset(p,0,MAX_LEN);
memset(s,0,MAX_LEN);
printf("Please input string: ");
scanf("%s",p);
while(*temp != '\0')
{
while(*temp >= '0' && *temp <= '9')
{
len++;
temp++;
}
if(len > max)
{
max = len;
for(i = 0;i < len;i++)
{
*(s_temp + i) = *(temp - len + i);
}
len = 0;
*(s_temp + i) = '\0';
}
temp++;
}
printf("The max countinue number of the string :%d\n",max);
printf("The countinue number string max is :%s\n",s);
return 0;
}
2.用函数交换两个数的值
#include <stdio.h>
void exchange(int *m, int *n)
{
int t;
t = *m;
*m = *n;
*n = t;
}
int main()
{
int a;
int b;
printf("Please input two number:");
scanf("%d %d",&a,&b);
exchange(&a, &b);
printf("The result of the two number is:a = %d, b = %d \n",a,b);
return 0;
}