CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

String concatenation at compile time

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Laurent Chouinard



Joined: 12 Sep 2003
Posts: 43

View user's profile Send private message

String concatenation at compile time
PostPosted: Tue Dec 11, 2007 8:08 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Tue Dec 11, 2007 8:39 am     Reply with quote

Hello, You can use the standard C function strcat(str1, str2) in "string.h"
Laurent Chouinard



Joined: 12 Sep 2003
Posts: 43

View user's profile Send private message

PostPosted: Tue Dec 11, 2007 8:45 am     Reply with quote

I mean concatenation at compile time, not at runtime.
Ken Johnson



Joined: 23 Mar 2006
Posts: 197
Location: Lewisburg, WV

View user's profile Send private message

PostPosted: Tue Dec 11, 2007 8:58 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Dec 11, 2007 9:04 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Dec 17, 2007 2:18 pm     Reply with quote

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";
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group