连接字符串(长度有限的字符串)

#include<stdio.h>
#include<iostream>
#include<stdlib.h>
using namespace std;
#define len 255

char* strcat(char *a, char *b){
    int lena = sizeof(a);
    int lenb = sizeof(b);
    for(int i = lena-1; i < len; )
        for(int j = 0; j < lenb; )
            a[i++] = b[j++];
    return a;
}
int main(){

    char a[len], b[len];
    cout << "please key in the first string:" << endl;
    cin >> a;
    cout << "please key in the second string:" << endl;
    cin >> b;
    strcat(a, b);
    cout << a << endl;
}
原文地址:https://www.cnblogs.com/digulove/p/8025181.html