赞
踩
#include <stdio.h> void f(char*str1,char*str2)//函数名为f,自定义字符串连接函数 { int i=0; while(str2[i]!=0) { str1[i]=str2[i];//把b复制到a中 i++; } str1[i]='\0';//添加字符串结束符 } int main() { char a[100],b[100]; puts("请输入字符串:\n"); gets(b);//字符串输入 f(a,b);//把b复制到a中 puts(a);//输出被复制到a中的字符串 return 0; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。