All pastes #412375 Raw Edit

Unnamed

public text v1 · immutable
#412375 ·published 2007-03-27 17:39 UTC
rendered paste body
#include <cstdlib>
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main(int argc, char *argv[])
{
    int position(0), position2(0), length(0), i(0);
    double number(0), sum(0);
    string str1, str2;
    
    stringstream stream;
    
    
    cout << "please enter a number";
    getline(cin, str1, '=');
    str1.insert(0, 1, '0');
    str1.insert(1, 1, '\n');
    int b(str1.length());
    //cout << str1;
    cout << b;
    system("PAUSE");
   while ( i <= b-3 )
          {  
            position = str1.find('\n', i);
            
            cout << "\nposition" << position;
            position2 = str1.find('\n', position+1);
            cout << "\nposition2" << position2;
            length = (position2 - position -1);
            cout << "\nlength";
            cout << length;
            
            system("PAUSE");
            
            
            str2.clear();
            str2 = str1.substr(position+1, length);
            cout << "\nstr2" << str2;
            stream.clear();
            stream << str2;
            stream >> number;
            sum += number;
            cout << "\nnumber="<<number;
            //position++;
            i=position2;
            cout << "\nI";
            cout << i;
            number = 0; 
            }
            cout<< "\nstr2";
    cout << str2;
    cout << "\nsum";
    cout << sum;
    system("PAUSE");
    return EXIT_SUCCESS;
}