7、将字符串数组s2中全部字符复制到字符数组s1中,不用strcpy函数

/*
将字符串数组s2中全部字符复制到字符数组s1中,不用strcpy函数
 */
#include <stdio.h>
#include <stdlib.h>

void strCpy(char *pStr1,char *pStr2)
{
    while(*pStr2 != '\0')
    {
        *pStr1 = *pStr2;
        ++pStr1;
        ++pStr2;
    }
    *pStr1 = '\0';
}

int main()
{
    char str1[100];
    char str2[100];
    scanf("%s %s", str1, str2);
    strCpy(str1,str2);
    printf("str1: %s", str1);
    //return 0;
}

posted @ 2021-09-22 21:14  叶梓渔  阅读(996)  评论(0)    收藏  举报