I’m new to C++ and my teacher gave me a practice program to write (It’s just for practice…not homework, and worth no points, so don’t worry) and what I have to do is read input from the standard input stream, compare it against some arbitrary strings and then later in the project I have to convert it to a double (thus I cannot read it directly as a double).
So far I can read it in and store it as a string string input; cin >> input; however, I don’t know how to convert it to a double. The problem is I’m only allowed to use the following libraries:
<iostream>, <string>, <cstdlib>, <stdio.h>, and <cassert>.
I’ve looked at atof in cstdlib but it only takes in a char * not a string. Any suggestions?
Simple: