0

Hello,

I have 2 wstring variables:

std:wstring first =L"Jose";
std:wstring second = L"James";

How can I combine these variables:

first + second

gives an error in Visual Studio.

Cheers

2
Contributors
3
Replies
31
Views
1 Year
Discussion Span
Last Post by rubberman
1

Assuming the target is also a wstring type, this should work. IE:
std::wstring newstr = first + L" " + second;

Note that you left off the second colon in your variable definitions. This may be your problem. What error are you getting? The following is a test program that I just wrote to test this on Linux using GCC 4.4.7. It works fine and the output is "John Doe" as expected.

#include <string>
#include <iostream>

int main()
{
    std::wstring first = L"John";
    std::wstring second = L"Doe";
    std::wstring full = first + L" " + second;
    std::wcout << full << std::endl;
    return 0;
}
0

So, you live on the Ile-de-France? Paris is a pretty big place! :-) Where are you going to school?

Votes + Comments
+1 for balance and peas.
0

I would have been a bit more snarky if you said you lived on the Ile de la Cite. :-) I don't think Notre Dame has student housing on the island... I spent a month on the Rive Gauche when I was a teen - even climbed to the top of Notre Dame with my father - no hunchback there though! What a dissapointment!

Edited by rubberman

Votes + Comments
Another for balance.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.