张一林//2018.07.17

苏嵌                                                                                                                              项目实战

学习日志                                     姓名:张一林       日期: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;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值