Alright, so what I would like to see happen is two strings attached. I know I can cout << them both and they will output an attached string, but what if i want to call the attached string in another area of my code?

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

int main() {
    string sztext1;
    string sztext2;
    string sztext3;
    cout << "Debug 1:" << endl;
    cin >> sztext1;
    cout << "Debug 2:" << endl;
    cin >> sztext2 >> sztext3;
    string fullstr = //sztext2 and sztext3 attached...
    return 0;

So If i type, hey, then i type 'you ok', i would like heyok to be fullstr. Thank you..

Recommended Answers

All 2 Replies

Whats wrong with the good ol' + operator?

string sztext2;
    string sztext3;
    cout << "Debug 2:" << endl;
    cin >> sztext2;
    cout << "Debug 3:" << endl;
    cin >> sztext3;

    string fullstr = sztext2+sztext3;
    cout << fullstr;

Wow, people like you are really helpful. Thanks, never even thought that would work!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.