自定义c语言字符串拷贝函数strcpy?

自定义c语言字符串拷贝函数strcpy


桃花长相依
浏览 1210回答 3
3回答

绝地无双

/*原 串 : Windows Application目标串 : Windows Application请按任意键继续. . .*/#include <stdio.h>#include <stdlib.h>char *strcopy(char ds[], char&nbsp;ss[]) {int i = 0;while(ds[i] =&nbsp;ss[i]) ++i;return ds;}int main() {char s[] = "Windows Application";char d[20];printf("原 串 : %s\n",s);printf("目标串 : %s\n",strcopy(d,s));system("pause");return 0;}

眼眸繁星

#include <stdio.h>char* cpystr(char *des, char *res){for(int i= 0; res[i]!='\0'; i++)des[i]= res[i];des[i]= '\0';return des;}int main (void){char d[30], s[]= "12345";cpystr(d, s);puts(d);return 0 ;}

一只萌萌小番薯

char* mystrcpy(char* dest, const char* src) {char*&nbsp;tmp&nbsp;= dest;while (*tmp++ = *src++);return dest;}
打开App,查看更多内容
随时随地看视频慕课网APP