- #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;
- }
字符串合并
原文:http://www.cnblogs.com/jiaojienku/p/4648797.html