Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

LiquidNRG

String Class

This topic is 6117 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

In my engine which I am developing I am using the new style C++ but as yet in the String class which I have done I have not been able to find a way round the following problems. The class has only member variables which are an int for the length and a char* for the data. 1. I want a constructor which takes a char* as an argument but i at the moment I need to use strlen so I can get the length. 2. I need a function to put int''s into the string and at the moment I have to use sprintf and this returns a length as well as having a char* to copy the data from into the class

Share this post


Link to post
Share on other sites
Advertisement
I''m not entirely sure what the question you''re asking is (both methods you''re using will work, after all), but I''m not sure why you''re not using std::string and std::stringstream.

Share this post


Link to post
Share on other sites
quote:
Original post by YourOtherLeft
1. I want a constructor which takes a char* as an argument but i at the moment I need to use strlen so I can get the length.


what''s wrong with strlen? well, anyways, you can go through the char* with a for loop, keep count of characters, and stop when you hit a 0 (''/0'').

--- krez (krezisback@aol.com)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
use the the standard string class, it has everything you need and more. Don''t bother making your own, unless you would rather work on a string class than a game.

Share this post


Link to post
Share on other sites

  • 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!