您的位置:首页 > 其它

字符串---字符串合并

2015-07-15 16:40 323 查看
#include"stdafx.h"

#include<iostream>

using namespace std;

void main(){

char s1[202], s2[101];

cout << "input the first string(Ended with ENTER)\n";

cin.getline(s1, 100);

cout << "input the second string(Ended with ENTER)\n";

cin.getline(s2, 100);

cout << "------------------------------------------\n";

int i=0, j=0, s1Len, s2Len, catLen;

while (s1[i])

i++;

s1Len = i;

while (s2[j])

s1[i++] = s2[j++];

s1[i] = '\0';

s2Len = j;

catLen = s1Len + s2Len;

cout << "The result cat_string is:" << endl;

cout << s1 << endl;

cout << "First string length=" << s1Len << endl;

cout << "Second string length=" << s2Len << endl;

cout << "Result cat_string length=" << catLen << endl;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: