字符数组操作(指针作函数参数)

#include 
using namespace std;

void mystrcpy(char *str1, char *str2) {
    while (*str2 != '\0') {
        *str1 = *str2;
        str1++;
        str2++;
    }
}

int main()
{
    char str1[] = "hello,";
    char str2[] = "world!";
    mystrcpy(str1, str2);
    cout << str1 << endl;

    return 0;
}

你可能感兴趣的:(字符数组操作(指针作函数参数))