字符复制

来源:百度知道 编辑:UC知道 时间:2024/09/21 04:08:12
编写一个字符串复制的程序。:
利用字符数组的 结构特点 来实现功能,不使用 strcpy() 函数
c++ hurry~~~~~~~~
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
还有把s改成destination为什么系统就报错呢?
char s[80];
char source[]="abcdefghijklmnopqrstuvwxyz";
int i=0;
int j=0;
while(source[j]!='\0')
s[j++]=source[i++];
s[j]='\0';
cout<<"复制后的字符串为:"<<s<<endl;
return 0;
}
这个有没有问题?

#include<iostream>
#include<cstring>
using namespace std;
void main()
{
char s[80];
char source[]="abcdefghijklmnopqrstuvwxyz";
cout<<"复制前的字符串为:"<<source<<endl;
int i=0;
int j=0;
while(source[j]!='\0')
s[j++]=source[i++];
s[j]='\0';
cout<<"复制后的字符串为:"<<s<<endl;
}

可以不用返回值的,上边是我按你编的程序改过的,你原来的也没错

用什么语言编啊?VB?C++?