/* * Copyright (c) 2013, 烟台大学计算机学院 * All rights reserved. * 作 者: * 完成日期:2013 年 12月 * 版 本 号:v1.0 * 问题描述:字符串str1和str2连接,连接后的结果存放到str1中! */ #include <iostream> using namespace std; void astrcat(char str1[],const char str2[]); int main() { char a[50]="Hello"; char b[50]=" world"; astrcat(a,b); cout<<"连接后:"<<a<<endl; return 0; } void astrcat(char str1[],const char str2[]) { int i,j; for(i=0;str1[i]!='\0';i++); //找到str1的末尾 for(j=0;str2[j]!='\0';i++,j++) { str1[i]=str2[j]; } str1='\0'; }
17--2--1连接1,2字符串后放在1中。
最新推荐文章于 2023-02-24 18:09:51 发布