title: Converting String to Double Function
body: <p>I'm trying to convert a string to a double from inside a function, and then return a boolean that will change based on if the conversion was successful or not. MY QUESTION is how can I check if conversion failed or not?</p>
  
  <pre><code>//function definitions
  bool isValidDouble(string inputString);
  
  bool isValidDouble(string inputString)
  {
      //Declarations
      bool validDouble = true;
      double convertedDouble = 0;
  
      convertedDouble = atof(inputString.c_str());
  
  
  //      validDouble = false;
  //      convertedDouble = 0;
  
      return validDouble;
  }
  
  // CODE FROM MAIN
  
  int main()
  {
      string userInput = "";
      cout &lt;&lt; "Please Enter a number to convert. ";
      cin &gt;&gt; userInput;
      isValidDouble(userInput);
      return 0;
  }
  </code></pre>