|
|
今日学习任务
|
嵌入式C语言开发实战
|
今日任务完成情况
| 今日任务按计划完成 1.熟练掌握了函数的调用过程(传参时:传实参变量名、传实参变量的地址) 2.熟练掌握字符串的操作;(实现并使用字符串处理函数) 3.熟练掌握数组的使用;(1-3 数组名的作用,数组的使用) 4.掌握右左法则的使用;(复杂定义声明解释)
|
今日开发中出现的问题汇总
| 1.一开始传实参变量名还是传实参变量的地址没有完全理解,没有区分开来 2.数组名和数组的地址还要结合图加深理解,从而理解*(*(aa + i) + j)等 |
今日未解决问题
| 无 |
今日开发收获 | 1.熟练掌握了函数的调用过程(传参时:当只使用不修改实参变量值时,传实参变量名;当修改实参变量值时,传实参变量的地址) 2.return 0 和exit(1) 的区别:当本函数结束时或程序正常退出时用return 0 ;而结束整个程序时或程序异常退出时用 exit(1) 3.熟练掌握字符串的操作;(实现并使用字符串处理函数)(strcpy 和strncpy、 strcat和 strncat、 strcmp 和strncmp的不同用法及区别) 3.熟练掌握数组的使用;(1-3 维数组名的作用,数组的使用)数组是指针常量,是静态分配 4.掌握右左法则的使用;(复杂定义声明解释)
|
自我评价
| 今天基本能够跟上老师的教学进程,在数组的地址和数组名还需要多梳理,熟练掌握 |
其他
| 无 |
1.实现并使用字符串处理函数(strcpy 和strncpy、 strcat和 strncat、 strcmp 和strncmp)
#include <stdio.h>
#include <string.h>
char * my_strcpy(char *p, char *s)
{
char *s_temp = s;
char *p_temp = p;
while(*s_temp != '\0')
{
*p_temp = *s_temp;
s_temp++;
p_temp++;
}
*p_temp = '\0';
return p;
}
char * my_strncpy(char *p, char *s,int len)
{
int i;
char *s_temp = s;
char *p_temp = p;
for(i = 0; i < len; i++)
{
*(p + i) = *( s + i);
}
*(p + i) ='\0';
return p;
}
char * my_strcat(char * q, char *s)
{
char *s_temp = s;
char *q_temp = q;
while(*q_temp != '\0')
{
q_temp++;
}
while(*s_temp != '\0')
{
*q_temp = *s_temp;
s_temp++;
q_temp++;
}
*q_temp = '\0';
return q;
}
char * my_strncat(char *q, char *s,int len)
{
int i;
char *s_temp = s;
char *q_temp = q;
while(*q_temp != '\0')
{
q_temp++;
}
for(i = 0; i < len; i++)
{
*(q_temp + i) = *( s_temp + i);
}
*(q_temp + i) = '\0';
return q;
}
int my_strcmp(char *q, char *s)
{
int t;
while(*s1 != '\0' && *s2 != '\0')
{
if(*s1 == *s2)
{
t = 0;
}
if(*s1 > *s2)
{
t = 1;
}
if(*s1 < *s2)
{
t = -1;
}
*s1++;
*s2++;
}
return t;
}
int main()
{
char p[100];
char *s = "hello world";
char q[100] = "hello world";
char *m = my_strcat(q,s);
char *ptr = my_strcpy(p, s);
char *t = my_strncpy(p,s,4);
char *ttr = my_strncat(q,s,5);
int *s3 = my_strcmp(q,s);
printf("s = %s\n",s);
printf("q = %s\n",m);
printf("p = %s\n",ptr);
printf("t = %s\n",t);
printf("ttr = %s\n",ttr);
printf("s3 = %d\n",s3);
return 0;
}