Sign in to follow this  

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

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

This topic is 4307 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this