c语言之利用指针复制字符串的几种形式
发布时间:2020-12-16 09:07:02 所属栏目:百科 来源:网络整理
导读:第一种: #includestdio.h #include iostream void copy_string( char * p1, char * p2) { for (; *p1 != ' ' ; *p1++,*p2++ ) { *p2 = * p1; } *p2 = ' ;} int main() { char * str1 = ( char *) " hello world " ; char str2[] = i am a student ; copy
第一种: #include<stdio.h> #include<iostream> void copy_string(char* p1,char* p2) { for (; *p1 != ' |