#include <stdio.h>

void my_strcpy(char s1[], char s2[]) {
    int i = 0;
    while (s2[i] != '\0') {
        s1[i] = s2[i];
        i++;
    }
    s1[i] = '\0';
}

int main() {
    char s1[100], s2[100];
    printf("请输入要复制的字符串:");
    scanf("%s", s2);

    my_strcpy(s1, s2);

    printf("复制后的字符串为:%s\n", s1);
    return 0;
}
写函数void my_strcpychar s1 char s2将s2中的字符串拷贝到数组s1中去。要求: 1不允许使用任何有关字符串处理的标准库函数。 2在主函数中输入字符串s2调用函数my_strcpy实现复制在主函数中输出s1。用vs2010的c语言编写

原文地址: https://www.cveoy.top/t/topic/bk95 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录