Jump to content
  • Advertisement
Sign in to follow this  
baker

how can i go about doing this? c++ strings and saving them

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

hello all, i was wondering if i can get some advice. i have been tasked to write a program that takes a string, save the fields in a structure, recreate the string and send it off to another system. how can i go about this? this program is going to be written in C++ and Java. Java is the gui side. The menu contains a message box where the user can enter data in the below format. incoming string from java to my C++ program "item 1:field 1 = 101/field 2 = 123/field 3 = jan/key = 1/n item 2:field 1 = 123e/field 2 = wef/field 3 = 2poj/key = 2/n item 3:field 1 = fgdf/field 2 = efwe/field 3 = poj/key = 3/n ... ENDLINE" this string will be passed to my program in C++. now here is the kicker. in my c++ side, i will have an object that will extract field 1, field 2, ... and save them to my objects attributes. kind of like class String storage { field1; field2; field3; ... } class realStorage { some data; list<storage> items; } ok, so what i need to do is for the incoming string, grab all the fields for item1 and store them in fields names in c++. how can i go about doing this? how can i extract whats in between / *** /? for example in the string, how can i go about saving into c++, the stuff inbetween the first instance of '/' to the next instance of '/'?

Share this post


Link to post
Share on other sites
Advertisement
Take a look at std::string, in the standard template library (STL), it's quite nice. :) Heh. Umm, then to extract stuff, there is a .substr() function, a .find() function, a .find_last_of() function, and a couple others, but those should help you do what you need.

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!