Working on long String in C++

M

manishsharma1

Hi,

I have one long String like this:

015EnvironmentData1........

I want to read first three character from it and convert them to
integer. This will be the length of the Name of the field and then
there is value. So if we take above example


015 means 15 - So we are going to read next 15 Character Starting with
E of "EnvironmentData" till "a".
Transfer it to come Variable say Field

Then I have to read the Value of this field which is followed by this
15 character long Field in the STring that is 1 in the above case.

I need help in Stripping of the String so that I can get all the
Fields and their values.

This has to be in C++. I am new at it. Please help.

Thanks in advance
 
V

Victor Bazarov

I have one long String like this:

015EnvironmentData1........

I want to read first three character from it and convert them to
integer. This will be the length of the Name of the field and then
there is value. So if we take above example


015 means 15 - So we are going to read next 15 Character Starting with
E of "EnvironmentData" till "a".
Transfer it to come Variable say Field

Then I have to read the Value of this field which is followed by this
15 character long Field in the STring that is 1 in the above case.

I need help in Stripping of the String so that I can get all the
Fields and their values.

This has to be in C++. I am new at it. Please help.

Something like

std::string const blah("015EnvironmentData1........");
int n = -1;
std::eek:stringstream os(blah.substr(0, 3));
os >> n;
std::string Field = blah.substr(3, n);
os.str() = blah.substr(3 + n, 1);
int Value = -1;
os >> Value;

This is untested and only intended to give an idea.

V
 
M

manishsharma1

Hi Victor,

Thanks for reply.

This String is coming to the Parsing function in the form of pointer
to the string. Could you please advice something like the above
solution that will work with Pointer to String.

Thanks
 
V

Victor Bazarov

This String is coming to the Parsing function in the form of pointer
to the string. Could you please advice something like the above
solution that will work with Pointer to String.

std::string const blah(Pointer_To_String);

Everyting else is pretty much the same.

V
 
M

manishsharma1

    std::string const blah(Pointer_To_String);

Everyting else is pretty much the same.

V

Hi Victor,

My code is Unicode and I have to use CstString. Please suggest some
solution related to that.

Thanks
 
P

peter koch

Hi Victor,

My code is Unicode and I have to use CstString. Please suggest some
solution related to that.
Ask somewhere where CstString is topical. This is not the place.

/Peter
 
M

manishsharma1

Can you suggest where to post it then. I am new to development world.

Thanks in Advance
 
P

peter koch

Can you suggest where to post it then. I am new to development world.

Thanks in Advance

Hello

I am afraid I don't know. I suppose you know the name of the library/
development environment you use? In that case it should be a matter of
minutes before googling e.g. google newsgroups should provide you with
the name of an appropriate newsgroup.

/Peter
 
M

manishsharma1

Hello

I am afraid I don't know. I suppose you know the name of the library/
development environment you use? In that case it should be a matter of
minutes before googling e.g. google newsgroups should provide you with
the name of an appropriate newsgroup.

/Peter

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,183
Messages
2,570,967
Members
47,516
Latest member
TobiasAxf

Latest Threads

Top