Can I use a variable to name other variables?

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

Was this solution helpful to you?

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:

Just Added Q & A:

Find solution

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.