//sLine is the string for(int l = 0; l < sLine.length(); l++) { string sNumber; if(sLine[l] == \'-\') { sNumber.push_back(sLine[l]); sN
It's displaying a zero for all nonrecognized characters, because atoi returns 0 when given a non-numeric string (like a space!)
atoi
0
However, what you want to do, is shockingly simple:
std::stringstream ss(sLine); int num; while(ss >> num) { cout << num; }