You can't cast a char to const char * like that... atof() expects adress of a C string and outputs a float. What are you trying to achieve?
You can't cast a char to const char * like that... atof() expects adress of a C string and outputs a float. What are you trying to achieve?
I edited it. maybe more clear now (convert each digit to double and psuh into vector)
Regards
Khem.... Lot to learn you still have, young one
Qt Code:
QVector<double> vec; std::string str; for(int i=0;i<str.length();i++){ int val = str[i] - '0'; if(val<0 || val>9) continue; vec.push_back((double)val); }To copy to clipboard, switch view to plain text mode
thanks but isn't there a way to use that iterator on the string, please?
EDIT: and why a cast at C style ( "(double)" I mean )
Last edited by mickey; 29th February 2008 at 00:11.
Regards
Use an iterator if you want - I don't mind. The heart of the solution is the conversion of a character to digit, not the way you traverse the string. The cast is "just in case" so that I'm more confident it compiles.
Bookmarks