Is this a good way to do this?
char* array = "blah blah"; char* array2 = "bloh bloh"; string str = string() + array + array2;
It is impossible to make a direct string str = array + array2 , cannot add 2 pointers. Or should I do it
string str = array + array2
string str(); str += array; str += array2;
I would write:
string str = string(array) + array2;
Please note that your second version is invalid code . You must remove the parentheses:
string str; str += array; str += array2;
Finally, array and array2 must be of type const char * .
array
array2
const
char *
There are many ways to do this:
string str(array); str += array2;
or
or even
string str = array + string(array2);
or string streams:
stringstream ss; ss << array << array2;
Source: https://habr.com/ru/post/1411586/More articles:CASE or COALESCE performance in the WHERE clause for MySQL - performanced3.js visual update - javascriptWhy is the string displayed in NSDictionary with quotes and others not? - iosWindow application in Eclipse with WindowBuilder - javaListening to mouse events (drag-and-drop) in MS Excel - eventsCopy and paste content from text box to cell range of worksheet? - vbaBash the original command that does not work with the file, curled from the Internet - urlphp sorting array and field of a certain rank - sortingWhy rake assets: precompilation in development causes problems, but not in my production environment - ruby-on-rails-3.1Java - Can a Client act simultaneously as a Server simultaneously or vice versa? - javaAll Articles