hi, i have this code:
#include<iostream>
#include<sstream>
#include<string>
using namespace std;
int main (char argc)
{
string n1 = "141+246+3+64";
int n2;
int pos = -1;
char toFind = '+';
do
{
pos = n1.find(toFind, pos+1);
if(pos != -1)
{
stringstream(n1) >> n2;
cout << n2 << endl;
cout << n1 << endl;
cout << pos << endl << endl;
n1 = n1.substr(pos);
}
} while( pos != -1 );
system("pause");
}
this is the output: 141
141+246+3+64
3
246
246+3+64
5
Press any key to continue . . .
I dont know why it wont find all of the +'s. Any solutions?