im trying to store each element of the string into a vector so that i can add the numbers individually. im not really looking for advice on implementation, im just curious why this happens.
edit:....nvm, i just figure out why, it adds the whole string into one vector element, so the rest are empty
anyone know how to add each element of this string into each element of the vector? for ex Result[0] = 4 and Result[1] = 5 and so on. cause right now, its doing Result[0] = 45699999
The simplest way I can think of is converting each character in the string into a digit and sticking that into an array of ints (or vector if you prefer). 'Number Character' - '0'
would give you a value 0-9.
wow amazing how just a little change makes it works and i hear i was going completely crazy and was going to try a whole different way. i guess istringstream and the "convert>>Result" was useless.
but can i asked why you did -'0'? i mean it works but i want to know why. cause if i just removed only the -'0'. i would get some crazy number.
edit: if i do not do the -'0' the output is just the ascii value of those nums, why does -'0' work?