学习日志 姓名:张一林 日期:07.17
|
|
今日学习任务
| 1、 熟练掌握野指针及如何防止野指针;(消灭野指针) 2、 熟练掌握多维指针的使用;(n维指针) 3、 熟练掌握字符串的操作;(实现并使用字符串处理函数) 4、函数的定义和声明 |
今日任务完成情况
(详细说明本日任务是否按计划完成,开发的代码量) | 1、 熟练掌握野指针及如何防止野指针;(消灭野指针) 2、 熟练掌握多维指针的使用;(n维指针) 3、 熟练掌握字符串的操作;(实现并使用字符串处理函数) 4、函数的定义和声明 |
今日开发中出现的问题汇总
| 无 |
今日未解决问题
| 无 |
今日开发收获 | 今天把指针的定义,用法都给搞清楚了,应用指针的优点和指针的操作也都掌握,对于具体的指针的写法,基本思路都已经清楚。对于函数的基本格式和编写代码的技巧都已掌握 |
自我评价
(是否按开发规范完成既定任务,需要改进的地方,与他人合作效果等)
| 今天的这堂课,刚开始回顾了之前的内容,在之后讲的内容听得有些吃力,但经过思考后也已经消化掉,对于指针掌握的不是很好,也需要敲代码来练习 |
其他
| 无 |
1.#include<stdio.h>
int main()
{
printf("int *= %d\n",sizeof(int *));
printf("char * = %d\n",sizeof(char *));
printf("float * = %d\n",sizeof(float*));
printf("double * = %d\n",sizeof(double*));
printf("long * = %d\n",sizeof(long*));
printf("short * = %d\n",sizeof(short*));
return 0;
}
2. #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX_LEN sizeof(char) * 50
int main()
{
char * ptr =(char *)malloc(MAX_LEN);
char *temp =ptr;
int i = 0;
int max = 0;
if(ptr == NULL)
{
printf("malloc error\n");
exit(1);
}
memset(ptr,0,MAX_LEN);
printf("PLease input the number:\n");
scanf("%s",ptr);
while(*temp != '\0')
{
if(*temp >= '0' && *temp <= '9')
{
i++;
if(i > max)
{
max = i;
}
}
else
{
i = 0;
}
temp++;
}
printf("the max_len is :%d\n",max);
free(ptr);
ptr = NULL;
return 0;
}
3. #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX_LEN sizeof(char) * 50
int main()
{
char * str = (char *)malloc(MAX_LEN);
char * ptr = (char *)malloc(MAX_LEN);
char *temp = ptr;
char *temp1 = str;
int i = 0;
int max = 0;
int t;
if(ptr == NULL || str == NULL)
{
printf("malloc error\n");
exit(1);
}
memset(ptr,0,MAX_LEN);
memset(str,0,MAX_LEN);
printf("PLease input the number:\n");
scanf("%s",ptr);
while(*temp != '\0')
{
if(*temp >= '0' && *temp <= '9')
{
i++;
if(i > max)
{
max = i;
temp1 = str;
for(t = 0;t < max;t++)
{
*(str + t) = *(temp - max + t + 1);
}
*(str + t) = '\0';
}
}
else
{
i = 0;
}
temp++;
}
printf("the max_len is :%d\n",max);
printf("%s\n",temp1);
free(ptr);
ptr = NULL;
return 0;
}
4. #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX_LEN sizeof(char) * 50
int main()
{
char *ptr = (char *)malloc(MAX_LEN);
char *temp = ptr;
if(ptr == NULL)
{
printf("malloc error! \n");
exit(1);
}
memset(ptr,0,MAX_LEN);
scanf("%s",ptr);
while(*temp != '\0')
{
printf("%c\n",*temp);
temp++;
}
free(ptr);
ptr = NULL;
return 0;
}