Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I've been looking at chunks of code and dealing with string assignments in C++.

 

String* myLog = S"myNewLog";

 

What is the 'S' before "myNewLog"; needed for? Is it involved with the pointer of String*?

Posted

it tells the compiler to treat it as a System.String as opposed to an array of characters.

 

"foo bar" = char value[] = {'f', 'o', 'o', ' ', 'b', 'a', 'r', '\0'};

String* value = "foo bar" //wont compile

String* value = new String("foo bar") // will compile

String* value = S"foo bar" //will compile

 

and you can do S"FOO BAR"->Substring() and so forth.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...