>That would work great, but that above solution wont work in this case.
Can you explain better why not? This code runs fine for me:
Code:
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
int main()
{
string polyString = "5x^3+-23x^12";
int c[10], e[10];
int n = sscanf(polyString.c_str(),
"%dx^%d%+%dx^%d+%dx^%d+%dx^%d+%dx^%d+%dx^%d+%dx^%d+%dx^%d+%dx^%d+%dx^%d",
&c[0],&e[0],&c[1],&e[1],&c[2],&e[2],&c[3],&e[3],&c[4],&e[4],&c[5],&e[5],
&c[6],&e[6],&c[7],&e[7],&c[8],&e[8],&c[9],&e[9]);
for (int i=0; i<n/2; ++i)
{
cout << c[i] << " " << e[i] << endl;
}
cin.get();
return 0;
}