复制字串 for (int len = 0; dst[len]=src[len]; len++) ; //循环判断语句为什么是 dst[len]=src[len]
程序的原文如下:
/*
复制字串
*/
#include <stdio.h>
//#include <iostream.h>
//--- 复制字串src到dst ---//
void strcopy(char dst[], const char src[])
{
for (int len = 0; dst[len]=src[len]; len++) //循环判断语句为什么是 dst[len]=src[len]
printf("len=%d",len);
//cout<<len<<endl;
}
int main(void)
{
char x[100];
char y[100] = "ABCD";
printf("y=%s",y);
//cout<<y;
printf("请输入字串x::\n");
//cout << "请输入字串x::";
//
scanf("%s",x);
//cin >> x;
strcopy(y, x); // 复制字串x到y
printf("字串y=%s\n",y);
//cout << "字串y是" <<y<< "。\n";
return (0);
}