How can I use stringstream to add tokens to a team name and then numbers to their respective variables?
-
-
Answer:
psh, why use string stream? string a = " your info 12234" ; string name , temp_string ; int team_num ; int counter = 0 , c2 = 0 ; while (isalpha(a[counter]) ) { name[counter] = a[counter] ; counter++ ; } while(isdigit(a[counter]) ) { temp_string[c2] = a[counter] ; counter++ ; c2++ ; } team_number = atoi(temp_string) ; Actually, that code won't satisfy your entire request. you will have to modify the second loop to do it again and then place 1 in the first and the second in the second. Get it?
Eric at Yahoo! Answers Visit the source
Other answers
psh, why use string stream? string a = " your info 12234" ; string name , temp_string ; int team_num ; int counter = 0 , c2 = 0 ; while (isalpha(a[counter]) ) { name[counter] = a[counter] ; counter++ ; } while(isdigit(a[counter]) ) { temp_string[c2] = a[counter] ; counter++ ; c2++ ; } team_number = atoi(temp_string) ; Actually, that code won't satisfy your entire request. you will have to modify the second loop to do it again and then place 1 in the first and the second in the second. Get it?
Daniel
Related Q & A:
- How can I use a button to retrieve a phone 'number' from contacts?Best solution by Stack Overflow
- How can I find Yahoo email address with only a full name?Best solution by Yahoo! Answers
- How Can I Use A Picture For My Avatar?Best solution by Yahoo! Answers
- How can I use my PC with a wireless printer?Best solution by pcmag.com
- How can I use to prepaid cards to make a purchase?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.