I'm relatively new to programming and I'm having a little bit of trouble. I'm putting together a calculator program that adds, subtracts, whatever. When the addition function is called, it prompts the user for the number of numbers they'd like to add. It then prompts them for the number.
I got stuck...if the user inputed anything but a valid double data type, the computer would go into an infinite loop; never again prompting the user for data, since they entered a data type that was not a double.
Eventually, I ended up coding a program called verify. Basically, it takes a string of characters, analyzes them and if it's a valid double number, converts it to a double. (Valid meaning no '-' signs anywhere but the front, only one decimal, no letters, no spaces, no null characters, and it accepts 0). Needless to say, this has been an incredible pain, having taken me about 10 - 12 hours to code. Everything works now, with the exception of "-letters" which returns 0. That should be fixed here shortly.
Now, my question is, since I now have calculator.cpp and verify.cpp, is there anyway that I can "link" those two programs together? I'd like to have the user input a string of characters from calculator.cpp, pass it to verify.cpp, which will then run it through the ringer, and if it passes all the conditions, return it as a data type of float. Is there a way to do that? Or do I need to implement this 200+ lines of code into calculator.exe?
P.S. - If anyone is interested in taking a look at the code, let me know and I will post it.