문자열 복사

#include <stdio.h>


void copy_1(char a[],char b[]);
void copy_2(char *a,char *b);
int main()
{
    char str1[20]="I Love China!";//      
    char str2[20];
    copy_1(str1,str2);// copy_1       
    printf("str2 is: %s
",str2);     char str3[]="I Love Motherland";//     copy_2(str3,str2);// copy_2     printf("str2 is: %s
",str2);     return 0; } void copy_1(char a[],char b[]) {     int i;     for(i=0;*(a+i)!='\0';i++)         *(b+i)=*(a+i);     *(b+i)='\0'; } void copy_2(char *p1,char *p2) {     for(;*p1!='\0';p1++,p2++)         *p2=*p1;     *p2='\0'; }

좋은 웹페이지 즐겨찾기