In further pursing my silly solution to lilostitch382's "assign string to int array" I have been hamstrung:
Execution pauses indefinitely at pos++.Code:#include <iostream> #include <string> using namespace std; class nlist : public string { public: nlist(string in) { assign(in); } int extract(size_t pos) { int retv = 0, m = 1; size_t end; while (at(pos) < '0'|| at(pos) > '9') { printf("%d %d\n",pos,at(pos)); fflush(stdout); pos++; } cout << "hey"; end = pos; while (at(end) > '0'&& at(end) < '9') end++; end--; while (end>=pos) { retv += (at(pos)-48)*m; m*=10; } return retv; } }; int main() { string src="1,44,56,33"; nlist nums(src); cout << nums << "\n" << nums.extract(1); return 0; }
WHY????



LinkBack URL
About LinkBacks



