int GetIntVal(string strConvert, int location) { int intReturn; intReturn = atoi(strConvert.c_str()); return(intReturn); }
I don't want it to read the whole string I just want it to read one part of the string
I am building an equation solver
string equation; cout << "Enter your equation, one variable (x(lowercase)), no exponents: "; cin >> equation; for(int i = 0; i < equation.size(); ++i) { if(equation[i] == 'x') { int coef = GetIntVal(equation, i - 1); cout << coef; } }
ANd I want it to read the coefficient right before the x but when I change the atoi function, it says c_str is not defined (I have no idea what the function does though)
Edited by sausage, 22 March 2009 - 04:39 PM.