I'm doing a project that reads some string reactions from file at formula e.g: (5A+3B=c+10D) as an input, i need to do a parsing for the string reaction so that i can extract &(split) integer values beside a char and put them into a vector i.e vector associated with the reaction here is :[5 3 1 10] i thought about std::strtok function but i think it cannot seperate integer values!!! can any one help me ?? here my try:
int main()
{
std::string input;
std::getline(std::cin, input);
std::stringstream stream(input);
while(1) {
int n;
stream >> n;
char * pch;
pch = strtok (input," ");
while (pch != NULL)
{
printf ("%s\n",pch);
pch = strtok (NULL, " ,.");
}
return 0;
}