#include<stdio.h> char* str_copy(char *d, const char *s) { char *t = d; while (*d++ = *s++) /*另一种解法*/ ; /*while(d[i] = s[i])*/ return t; /* i++; */ } int main(void) { char str[128] = "ABC"; char tmp[128]; printf("str = \"%s\"\n", str); printf("复制的是:", tmp); scanf("%s", tmp); str_copy(str, tmp); puts("复制了。"); printf("str = \"%s\"\n",str); return 0; }
指针复制字符串
猜你喜欢
转载自blog.csdn.net/weixin_39690617/article/details/79563625
今日推荐
周排行