Jump to content
  • Advertisement
Sign in to follow this  
p997

[.net] String manipulation

This topic is 4592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, pls excused me for asking a newbie question, but how do i extract individual char out of a string? For example, i have a string(called field)which contains 13 letters, how do i loop through the string and extract each char inside of it? for (int i = 0; i< 13; i++) { switch (field(i)) <--- Obviously wrong, but what should i put in there? { case "w": .... break; case "e": .... break; . . . default: break; } } Thanks in advance for the helps.

Share this post


Link to post
Share on other sites
Advertisement
Strings overload the bracket operator []. Try "field" for the character at position i. Also, the size of the string (13) can also be gotten from field.size().

Share this post


Link to post
Share on other sites
Quote:
Original post by p997
hehe, thx. how silly of me to use () instead of [] as an array.

Not silly, just the wrong language. [grin]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!