Concatenate char arrays in C++

In C++, use std::string, and the operator+, it is designed specifically to solve problems like this.

#include <iostream>
#include <string>
using namespace std;

int main()
{
    string foo( "hello" );
    string test( "how are" );
    cout << foo + " , " + test;
    return 0;
}

Leave a Comment