回覆列表
-
1 # 被囚禁的王者
-
2 # 使用者5635123734932
#include
using namespace std;
int
main()
{
char stra[100],strb[100],str[200];//str=stra+strb
int i,j;
cout
cout
cin>>stra;//cin輸入字串不要包含空格否則請用getline()
cout
cout
cin>>strb;
for(i=0;stra[i]!="\0";i++)
str[i]=stra[i];
for(j=0;strb[j]!="\0";j++,i++)
str[i]=strb[j];
str[i]="\0";
cout
return 0;
}
#include<iostream>using namespace std;intmain(){ char stra[100],strb[100],str[200];//str=stra+strb int i,j; cout<<"Input stra(less than 100 characters):"<<endl; cout<<"stra="; cin>>stra;//cin輸入字串不要包含空格否則請用getline() cout<<"Input strb(less than 100 characters):"<<endl; cout<<"strb="; cin>>strb; for(i=0;stra[i]!="\0";i++) str[i]=stra[i]; for(j=0;strb[j]!="\0";j++,i++) str[i]=strb[j]; str[i]="\0"; cout<<"str=stra+strb="<<str<<endl; return 0;}