1. 程式人生 > >C語言學習(24)

C語言學習(24)

main png inf 參數 clas c語言 printf void ret

 1 //用字符串指針作為函數參數,試下字符串的復制
 2 #include<stdio.h>
 3 void cpystr(char *pss,char *pds){
 4     while(  (*pds=*pss)!=\0 ){
 5         pss++;
 6         pds++;
 7     }
 8 }
 9 
10 int main(){
11     char *pss="This is a book",b[100],*pds;
12     pds=b;
13     cpystr(pss,pds);
14     printf("復制後的字符串為:%s\n
",pds); 15 return 0; 16 }

技術分享圖片

C語言學習(24)