//苏嵌//韦庆宏//2018.7.17

 

 

今日学习任务

1、 熟练掌握野指针及如何防止野指针;(消灭野指针) 
2、 熟练掌握多维指针的使用;(n维指针) 
3、 熟练掌握字符串的操作;(实现并使用字符串处理函数) 

 

日任务完成情况

 

完成老师bu'z布置任务

完成老师布置作业

 

开发中出现的问题汇总

 

没有给指针分配空间,造成段错误

较少使用函数

 

 

日未解决问题

 

日开发收获

学会了代码的编写规范,为以后的工作打下了良好的基础

学会了函数在定义,调用,声明时候编写的规范。

 

自我评

 

 

今天学习过程中,了解许多关于指针的知识,知道了什么叫野指针,如何减少运用指针的错误。

 

  1 #include <stdio.h>
  2 #include <stdlib.h>
  3 #include <string.h>
  4 
  5 #define MAX_LEN sizeof(char) * 100
  6 int main()
  7 {
  8     char *ptr = (char *)malloc(MAX_LEN);
  9     char *s = (char *)malloc(MAX_LEN);
 10 
 11     char *p_temp=ptr;
 12     char *s_temp=s;
 13 
 14     int i;
 15     int max = 0;
 16     int count = 0;
 17 
 18     printf("please input string:\n");
 19     scanf("%s",ptr);
 20     p_temp = ptr;
 21 
 22 
 23     if(ptr == NULL || s == NULL)

 printf("malloc error!\n");
 26         exit(1);
 27     }
 28     memset(ptr,0,MAX_LEN);
 29     memset(s,0,MAX_LEN);
 30 
 31 
 32     while(*p_temp != '\0')
 33     {
 34         if((*p_temp >= '0') && (*p_temp <= '9'))
 35         {
 36             count++;
 37 
 38         }
 39         if(count > max)
 40         {
 41             max = count;
 42             s_temp = s;
 43             s = p_temp - count;
 44             for(i = 0;i < count;i++)

 45             {
 46                 *(s + i) = *(p_temp + i);
 47             }
 48             *(s + i)= '\0';
 49         }
 50         else
 51         {
 52             count = 0;
 53         }
 54         p_temp++;
 55     }
 56 
 57     printf("the max count is:%d\n",max);
 58     printf("%s\n",s_temp);
 59 
 60     free(ptr);
 61     free(s);
 62     ptr = NULL;
 63     s = NULL;
 64 }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值