Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Parsing strings
Hello.
How to parsing a string as str?
stringstream strs;
strs<<"U@1"<<"Vec@(2,4)";
string str = strs.str();
/*
* How to parsing the str ?
*/
Thanks for answering to my question.
Posted 25-Feb-12 0:34am
smss IR399
Comments
Richard MacCutchan at 25-Feb-12 6:51am
   
Parsing for what?
Member 8238193 at 25-Feb-12 6:59am
   
for discern parameters.
On String exist many parameters such as Number(Player number on footbal [robocup]),Vector(Vector of target to going that).
I want to discern parameters for doing actions on WrightEagleBASE for robocup soccer simulation ( www.wrighteagle.org/2d ).
for example, if string have "U@1V@(2,4)" then Player Number one , move to Point (2,4)
Richard MacCutchan at 25-Feb-12 7:10am
   
You can use one of the string member functions to find the specific items within the string.
Member 8238193 at 25-Feb-12 7:58am
   
how can?
Richard MacCutchan at 25-Feb-12 8:03am
   
By writing some code. I suggest you follow the link I provided and decide which member functions you need to use to get the results you want.
Member 8238193 at 25-Feb-12 8:08am
   
Your mean of link is wrighteagle.org ?
Edward Nutting at 25-Feb-12 8:55am
   
No he means the link in his comment...The one that takes you to the MSDN page that you need to look at (the one you should have found yourself)...this one:
http://msdn.microsoft.com/en-us/library/xabz5s9c.aspx
Member 8238193 at 25-Feb-12 10:01am
   
i can not understanding that link (http://msdn.microsoft.com/en-us/library/xabz5s9c.aspx)
because I wanna to parse a string and i saw on that link, a specialization & prototype of string.
and i do not see any function for parsing.
Thanks for answering, Please help me to understand how to parsing a string.
Richard MacCutchan at 25-Feb-12 10:38am
   
As I said before, you need to write some code, there is no existing function to parse your strings. Remember that the string you wish to parse is just a stream of characters, and it's up to you to design and write the algorithm that will split it into its constituent parts.
 

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

u will get the char* using function string::c_str(), which can be used with sscanf function for easy parsing..
 
Hopes this helps somewhat..
jkchan
http://cgmath.blogspot.com[^]
  Permalink  
Comments
Randor at 25-Feb-12 17:54pm
   
But your profile says that you are from the United States. :)
jk chan at 26-Feb-12 7:36am
   
i was lazy.
Member 8238193 at 26-Feb-12 8:04am
   
I quote from my friend :D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 480
1 mhegazy94 460
2 Ravi Bhavnani 190
3 Kornfeld Eliyahu Peter 185
4 Shemeemsha RA 160
0 Sergey Alexandrovich Kryukov 7,205
1 OriginalGriff 6,801
2 CPallini 5,350
3 George Jonsson 3,644
4 Gihan Liyanage 2,797


Advertise | Privacy | Mobile
Web02 | 2.8.140922.1 | Last Updated 25 Feb 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100