- 14
- 0
- 约1.84万字
- 约 102页
- 2019-12-08 发布于北京
- 举报
《0.研究性学习-交际中的语言艺术
第十章 10.1地址和指针的概念 10.2 变量的指针和指向变量的指针变量 10.4.2 字符指针作函数参数 例10.110 用函数调用实现字符串的复制 #include stdio.h void main() {void copy_string(char *from, char *to); char *a=I am a teacher.; char b[]=You are a student.; char *p=b; printf(string a=%s\nstring b=%s\n,a,p); printf(copy string a to string b:\n ); copy_string(a,p); printf(\nstring a=%s\nstring b=%s\n,a,b); } (1) 用字符数组作参数 void copy_string(char *from, char *to) { for(;*from!=\0;from++,to++) {*to=*from;} *to=\0; } 程序运行结果如下: string a=I am a teacher. string b =You are a student. copy string a to string b: string a =I am a te
原创力文档

文档评论(0)