#include "stdafx.h"
#include "string.h"
#include "iostream"
int strlen(char* a);
void strcpy(char *a,char *b);
void strcat(char *a,char *b,char *c);
using namespace std;
int main()
{ char a[]={"uestc"};
char b[]={"of China"};
char c[strlen(a)+strlen(b)];
cout<< "原字符串为:";
cout<< "a="<<a<<endl<<"b="<<b<<endl;
cout<< "a的长度:" <<strlen(a)<<endl;
cout<< "b的长度:" <<strlen(b)<<endl;
cout<< "字符串a,b复制后的结果是:"<< strcpy(a,b);
cout<<"字符串a,b连接后的结果是:"<< strcat(a,b,c);
return 0;
}
int strlen(char* a)
{
int num=0;
while(a[num]!='\0'){
num++;
}
return num;
}
void strcpy(char *a,char *b)
{ int i=0;
while(i<= strlen(b))
{ a[i]=b[i];
i++; }
cout << "复制后的字符串a为:" << a << endl;
void strcat(char *a,char *b,char *c)
{
int i;
for(i=0;i< strlen(a);i++){
c[i]=a[i];
}
for(i= strlen(a);i<= strlen(c);i++){
c[i]=b[i- strlen(a)];}
}
#include "string.h"
#include "iostream"
int strlen(char* a);
void strcpy(char *a,char *b);
void strcat(char *a,char *b,char *c);
using namespace std;
int main()
{ char a[]={"uestc"};
char b[]={"of China"};
char c[strlen(a)+strlen(b)];
cout<< "原字符串为:";
cout<< "a="<<a<<endl<<"b="<<b<<endl;
cout<< "a的长度:" <<strlen(a)<<endl;
cout<< "b的长度:" <<strlen(b)<<endl;
cout<< "字符串a,b复制后的结果是:"<< strcpy(a,b);
cout<<"字符串a,b连接后的结果是:"<< strcat(a,b,c);
return 0;
}
int strlen(char* a)
{
int num=0;
while(a[num]!='\0'){
num++;
}
return num;
}
void strcpy(char *a,char *b)
{ int i=0;
while(i<= strlen(b))
{ a[i]=b[i];
i++; }
cout << "复制后的字符串a为:" << a << endl;
void strcat(char *a,char *b,char *c)
{
int i;
for(i=0;i< strlen(a);i++){
c[i]=a[i];
}
for(i= strlen(a);i<= strlen(c);i++){
c[i]=b[i- strlen(a)];}
}