• Advertisement
Sign in to follow this  

Storing a string in a struct

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

I'm trying to store a string in a struct. Do I need different call names for the string and the string when it's in the struct? What is the correct syntax for something like this?

Share this post


Link to post
Share on other sites
Advertisement
I have no clue what you are asking. What language are you talking about? What do you mean by 'call name'?

Share this post


Link to post
Share on other sites

Are you talking about a c-string (char array) or a c++ string (STL), those are totally different thing. But anyway, you write them pretty much the same way as without a struct:

 

struct SomeStruct {

    char Buffer[256];

};

 

or

 

struct SomeStruct {

    std::string s;

};

Edited by Vortez

Share this post


Link to post
Share on other sites

Sorry BitMaster, I thought that since I tagged the language I was covering the bases, but I can elaborate next time!

 

Thanks vortez that is extremely helpful :)

Share this post


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

  • Advertisement