I have to write a program that I thought would be pretty easy to solve, but I am lost and dont know what to do. The problem is to read in floating point numbers character by character. The problem will separate the whole number into an integer, and the fractional part into an integer, and disregard any non numeral characters.
I though maybe i could store the value in a string and then try and type cast it to an int value, but cant type cast a string into an int value...
I have no clue on how to do this. I cant think of a way to reassemble the read in characters and still be a number value. Anyone point me in the right direction?
I don't understand why you are doing that.^
Also calling system("pause"); is evil, it might not work on all systems, and there are much better ways of pausing a program.
and out goes simple... i am super confused now. the only thing ive ever used .c_str() for is converting an input into a vaild format for a text file. i never read the details on it and that is way over my head right now. and i see char[] all over the place here but i dont understand that either. The part that frustrates me the most is that i dont think the text book that i am working out of gave enough resources so far in order to solve this problem.
str1 = inputString.substr(0,dotPos); // <--- supposed to store numbers up to the dot in floating point number
str1 = inputString.substr(dotPos + 1, 255); // <-- supposed to store digits after dot in floating point number
I just wanted to see if i could use atoi() and that seemed like the easiest way to give a test run on what my main program is supposed to do.