View previous topic :: View next topic |
Author |
Message |
Laurent Chouinard
Joined: 12 Sep 2003 Posts: 43
|
String concatenation at compile time |
Posted: Tue Dec 11, 2007 8:08 am |
|
|
I would like to know if there is a way to do string concatenation at compile time, like:
Code: | In PHP i would do "blah" . "something"
In VB I would do: "blah" & "something" |
and it appears as one string to the code.
Anything available for the CCS compiler? (v3) |
|
|
JoaoSantos
Joined: 19 Jun 2007 Posts: 20 Location: Castelo Branco, Portugal
|
|
Posted: Tue Dec 11, 2007 8:39 am |
|
|
Hello, You can use the standard C function strcat(str1, str2) in "string.h" |
|
|
Laurent Chouinard
Joined: 12 Sep 2003 Posts: 43
|
|
Posted: Tue Dec 11, 2007 8:45 am |
|
|
I mean concatenation at compile time, not at runtime. |
|
|
Ken Johnson
Joined: 23 Mar 2006 Posts: 197 Location: Lewisburg, WV
|
|
Posted: Tue Dec 11, 2007 8:58 am |
|
|
I believe you simply write the strings as:
"string1" "string2" "etc"
and the compiler will make one string of all.
Ken |
|
|
Laurent Chouinard
Joined: 12 Sep 2003 Posts: 43
|
|
Posted: Tue Dec 11, 2007 9:04 am |
|
|
Yes! Thank you, it works.
I assumed the compiler required a character to do it, like most other... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Dec 17, 2007 2:18 pm |
|
|
I think this is standard behavior for compilers. The following is from
the help file for MSVC++:
Quote: |
When specifying string literals, adjacent strings are concatenated. Therefore, this declaration:
char szStr[] = "12" "34";
is identical to this declaration:
char szStr[] = "1234";
|
|
|
|
|