字符串---字符串合并
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;
}
#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;
}
相关文章推荐
- Ubuntu 安装与使用 Rootkit 扫描程序
- MySQL Study之--MySQL下图形工具的使用(phpMyAdmin)
- Codeforces Round #312 (Div. 2) C. Amr and Chemistry dp 搜索
- 并发 并行 同步 异步 多线程的区别
- iOS7 images.xcassets里面放入资源图片
- 安卓Bitmap读取图片
- CTSC1999补丁VS错误题解
- Android获取meta-data
- ecshop广告调用方法
- SWFUpload学习记录
- linux中的设备节点
- 基于Aspose.Words 生成Word文件
- C++ Json处理
- eclipse Package Explorer的设置探索
- Afinal的FinalActivity的注解学习笔记
- C# 结构体访问器错误提示
- 2.2-1 文章模块开发 【入口脚本及模板的创建】
- Linux系统性能分析
- TestFlight——完美的iOS app测试方案
- 如何学习hybris?