我认为有一些微不足道的非常愚蠢的错误,但我无法确定它。有什么建议吗?
string stuff = "5x^9";
istringstream sss(stuff);
double coeff;
char x, sym;
int degree;
sss >> coeff >> x >> sym >> degree;
cout << "the coeff " << coeff << endl;
cout << "the x " << x << endl;
cout << "the ^ thingy " << sym << endl;
cout << "the exponent " << degree << endl;
输出:
the coeff 0
the x
the ^ thingy
the exponent 1497139744
它应该是,我想
the coeff 5
the x x
the ^ thingy ^
the exponent 9