Guest User

Untitled

a guest
Jan 12th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <string.h>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main ()
  6. {
  7.     int risultato;
  8.   char str[] = "2+3+4" ;
  9.   char * num1 ;
  10.   int somma;
  11.  
  12.  
  13.   cout << "Prova" << "\n" << endl;
  14.   cout <<"Scrivere l'espressione.." << endl;
  15.  
  16.  
  17.   cout << "\n" << str << endl;
  18.   num1 = strtok (str,"+");
  19.   somma = somma + (int) num1;
  20.   while (num1 != NULL)
  21.   {
  22.  
  23.     cout << "\n" << num1 << endl;
  24.     num1 = strtok (NULL, "+");
  25.       somma = somma + (int) num1;
  26.  
  27.     cout << "\n" << num1 << endl;
  28.       somma = somma + (int) num1;
  29.  
  30.     num1 = strtok (NULL, "+");
  31.     cout << somma << endl;
  32.  
  33.   }
  34.  
  35. return 0;
  36. }
Add Comment
Please, Sign In to add comment