daily pastebin goal
78%
SHARE
TWEET

Untitled

a guest Jan 12th, 2018 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top