I have a problem with converting this input: 1/2 + 3/4 for example. This input is given as string. How can I convert it into integers and do the addition with this fractions. Here is my code:
int main()
{
char input[30];
cin.getline(input, 30);
char *tok;
tok = strtok(input, "+ /");
while (tok != NULL)
{
cout << tok << endl;
tok = strtok(NULL, "+ /");
}
return 0;
}
I splitted the string and extracted the numbers but they are still a chars, so how can i convert them into ints in that while loop?