String Construct in NXC

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
bungeshea
Posts: 207
Joined: 14 Aug 2011, 08:45
Location: Australia
Contact:

String Construct in NXC

Post by bungeshea »

Is there a way of combining text strings in NXC (like the NXT-G "Text" block)? I have tried searching here for it, but I cannot find it.
timpattinson
Posts: 224
Joined: 30 Oct 2010, 04:10
Location: 127.0.0.1
Contact:

Re: String Construct in NXC

Post by timpattinson »

StrCat("abc","123");
?
yay for inline codetags "["c"]" "["/c"]"
Commit to Lego Mindstorms StackExchange Q&A http://area51.stackexchange.com/proposals/4105
Minboards IRC Channel #mindboards on Freenode
My blog: http://timpattinson.wordpress.com/
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: String Construct in NXC

Post by muntoo »

Or, you can simply use the + operator:

Code: Select all

string helloworld = "hello" + " " + "world";
It works because + has a special meaning for strings. (In C++, it's "overloaded".)
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest