下面代码的*p都是什么意思啊

#include <stdio.h>
 
copystr(char *p1, char *p2, int m)
{               
    int n;
 
    n = 0;
    while (n < m - 1)
    {               
        n++;
        p1++;
    }
    while (*p1 != '\0')
    {               
        *p2 = *p1;
        p1++;
        p2++;
    }
    *p2 = '\0';
}               
 
int main(void)
{               
    int m;
    char str1[20], str2[20];
 
    printf("请输入一个字符串:\n");
    scanf("%s", str1);
    printf("从第几个字符开始复制?");
    scanf("%d", &m);
    if (strlen(str1) < m)
    {               
        printf("输入错误。");
    }
    else
    {               
        copystr(str1, str2, m);
        printf("复制结果为:%s", str2);
    }
 
    return 0;
}

qq_半夏流年_0
浏览 2361回答 3
3回答

qq_老鼠爱大米_1

第二行的char*指的是定义了一个字符型指针,它指向一个字符变量(这个可能有些不准确),while (*p1 != '\0')中的*p1指的是p1这个指针所指的内容(即传递的字符串str1),*p2 = '\0';中的*p2也是这样

慕仔9441206

指针所指的对象
打开App,查看更多内容
随时随地看视频慕课网APP