Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.h>
- #include <iostream>
- using namespace std;
- int main ()
- {
- int risultato;
- char str[] = "2+3+4" ;
- char * num1 ;
- int somma;
- cout << "Prova" << "\n" << endl;
- cout <<"Scrivere l'espressione.." << endl;
- cout << "\n" << str << endl;
- num1 = strtok (str,"+");
- somma = somma + (int) num1;
- while (num1 != NULL)
- {
- cout << "\n" << num1 << endl;
- num1 = strtok (NULL, "+");
- somma = somma + (int) num1;
- cout << "\n" << num1 << endl;
- somma = somma + (int) num1;
- num1 = strtok (NULL, "+");
- cout << somma << endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment