苏嵌//杨曼曼//7.17

 

 

 

 

今日学习任务

 

  1. 算术运算符、条件运算符、特殊运算符的相关知识;
  2. 指针的定义、功能、字节长度
  3. * &运算符的作用
  4. 多维指针的作用
  5. 什么是野指针
  6. 如何避免野指针
  7. 函数的基本语法和程序框架

日任务完成情况

 

 

今日学习任务按照计划完成。

1.算术运算符、条件运算符、特殊运算符的相关知识;

2.指针的定义、功能、字节长度

3.* &运算符的作用

4.多维指针的作用

5.什么是野指针

6.如何避免野指针

7.函数的基本语法和程序框架

日开发中出现的问题汇总

 

  1. 避免野指针的程序复杂
  2. 函数的返回值类型弄错

 

日未解决问题

 

日开发收获

今天接着C语言的复习,重温了以前的指针和函数知识点,相较于以前的,老师通过图形让我更深地了解了指针的定义,也懂得了很多的新知识,老师拿经典的面试题给我们做,也让我们了解了很多C语音的有趣点。

 

自我评

 

 

 

今天学习任务基本按计划完成,对C语言的知识点又做到了巩固,同时发现以前所学的东西遗忘的很多。

其他

 

 

代码:

  1. 计算指针变量的字节长度

#include <stdio.h>

 

int main()

{

    printf("int * len = %d\n", sizeof(int *));

    printf("char * len = %d\n", sizeof(char *));

    printf("double * len = %d\n", sizeof(double *));

    printf("float * len = %d\n", sizeof(float *));

 

    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;

 

    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;

 

}

3.

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#define MAX_LEN  sizeof(char) * 50

 

int main()

{

    int i;

    int max = 0;

    int len = 0;

 

    char *ptr = (char *)malloc(MAX_LEN);

    char *str = (char *)malloc(MAX_LEN);

 

    char *temp = ptr;

    char *s_temp = str;

 

    if(ptr == NULL || str == NULL)

    {

        printf("malloc error!\n");

exit(1);

    }

    memset (ptr,0,MAX_LEN);

    memset (str,0,MAX_LEN);

 

 

    printf("Please input string:\n");

    scanf("%s",ptr);

    temp = ptr;

 

    while(*temp != '\0')

    {

        if(( *temp >= '0') && (*temp <= '9'))

{

      len++;

      

              if( len > max)

              {

                  max = len;

  s_temp = str;

    

          for(i = 0; i < max; i++)

          {

              *(s_temp + i) = *(temp - max + i + 1);

 

          }

                  *(s_temp + i) = '\0';

        

       }

 }

    

         

 else

 {

     len = 0;

 }

 temp++;

    }

 

        printf("the continue number string max len = %d\n",max);

        printf("the result =  %s\n", s_temp);

 

        return 0;

 

}

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值