string-concatenation

Concatenate two char arrays?

大兔子大兔子 提交于 2019-12-21 03:31:02
问题 If I have two char arrays like so: char one[200]; char two[200]; And I then want to make a third which concatenates these how could I do it? I have tried: char three[400]; strcpy(three, one); strcat(three, two); But this doesn't seem to work. It does if one and two are setup like this: char *one = "data"; char *two = "more data"; Anyone got any idea how to fix this? Thanks 回答1: If 'one' and 'two' does not contain a '\0' terminated string, then you can use this: memcpy(tree, one, 200); memcpy(

Performance: Java's String.format [duplicate]

≡放荡痞女 提交于 2019-12-20 18:33:46
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Should I use Java's String.format() if performance is important? I was wondering if is good to use String.format in Java apps instead of StringBuilder ... so, I just write a simple test, like this: public static void main(String[] args) { int i = 0; Long start = System.currentTimeMillis(); while (i < 10000) { String s = String.format("test %d", i); i++; } System.out.println(System.currentTimeMillis() - start); i

Android StringBuilder vs String Concatenation

放肆的年华 提交于 2019-12-20 12:03:44
问题 I was reading this documentation page, http://developer.android.com/reference/android/util/Log.html. The section here caught my eye: Tip: Don't forget that when you make a call like Log.v(TAG, "index=" + i); that when you're building the string to pass into Log.d, the compiler uses a StringBuilder and at least three allocations occur: the StringBuilder itself, the buffer, and the String object. Realistically, there is also another buffer allocation and copy, and even more pressure on the gc.

Concat strings in a shell script [duplicate]

别等时光非礼了梦想. 提交于 2019-12-20 09:09:29
问题 This question already has answers here : How to concatenate string variables in Bash (30 answers) Closed 3 years ago . How can I concat strings in shell? Is it just... var = 'my'; var .= 'string'; ? 回答1: How about this: var="${var}string" 回答2: It depends on the shell, but since question was tagged bash: var='my' var=$var'string' 回答3: No. For various reasons. # most sh-compatible shells var="my" var="$var string" # advanced shells var="my" var+=" string" 来源: https://stackoverflow.com/questions

conditionally concatenate text from multiple records in vba

孤街醉人 提交于 2019-12-20 06:58:44
问题 Sample Data: UniqueID Description ConsolidatedText Str1 Here is a sentence Here is a sentence Str2 And another sentence. And another sentence. And some words Str2 And some words Str3 123 123 Str4 abc abc ###" Str5 ### I have a number of records (~4000) each with a UniqueID value (text) and a text field (potentially quite lengthy) which is a user-entered description of the data. I need to consolidate the spreadsheet by concatenating all the descriptions into a single record where there are

conditionally concatenate text from multiple records in vba

Deadly 提交于 2019-12-20 06:58:07
问题 Sample Data: UniqueID Description ConsolidatedText Str1 Here is a sentence Here is a sentence Str2 And another sentence. And another sentence. And some words Str2 And some words Str3 123 123 Str4 abc abc ###" Str5 ### I have a number of records (~4000) each with a UniqueID value (text) and a text field (potentially quite lengthy) which is a user-entered description of the data. I need to consolidate the spreadsheet by concatenating all the descriptions into a single record where there are

Difference between c++ string append and operator +=

萝らか妹 提交于 2019-12-19 17:45:42
问题 Is there any noticeable difference between the two lines? My coworker says that using += is "faster" but I don't see why they should be any different: string s1 = "hello"; string s2 = " world"; // Option 1 s1 += s2; // Option 2 s1.append(s2); To clarify, I am not asking about the usage differences between the two functions - I am aware that append() can be used for a wider variety of uses and that operator += is somewhat more specialized. What I care about is how this particular example gets

Read content from text file formed in Windows in Linux bash [duplicate]

泪湿孤枕 提交于 2019-12-19 17:39:08
问题 This question already has answers here : How to concatenate string variables in Bash (30 answers) Closed 5 years ago . I am trying to download files from a database using wget and url. E.g. wget "http://www.rcsb.org/pdb/files/1BXS.pdb" So format of the url is as such: http://www.rcsb.org/pdb/files/($idnumber).pdb" But I have many files to download; so I wrote a bash script that reads id_numbers from a text file, forms url string and downloads by wget. !/bin/bash while read line do url="http:/

Concatenation of strings by for xml path

淺唱寂寞╮ 提交于 2019-12-19 09:26:50
问题 Hi! Today I learned for xml path technique to concatenate strings in mssql. Since I've never worked with xml in mssql and google hasn't helped, I need to ask you. Let's imagine the default case. We need to concatenate some strings from a table: declare @xmlRepNames xml = ( select ', [' + report_name + ']' from ( select distinct report_order, report_name from #report ) x order by report_order for xml path(''), type) select stuff((select @xmlRepNames.value('.', 'nvarchar(max)')), 1, 1, '') So I

Row-wise sort then concatenate across specific columns of data frame

一笑奈何 提交于 2019-12-19 06:54:50
问题 (Related question that does not include sorting. It's easy to just use paste when you don't need to sort.) I have a less-than-ideally-structured table with character columns that are generic "item1","item2" etc. I would like to create a new character variable that is the alphabetized, comma-separated concatenation of these columns. So for example, in row 5, if item1 = "milk", item2 = "eggs", and item3 = "butter", the new variable in row 5 might be "butter, eggs, milk" I wrote a function f()