Here's an example of using strtod(). It seems to work for values from 1e-300 to 1e300. I goes a little freaky if I input 1e1000000000 or something similarly small, but that's probably because I don't know how to handle HUGE_VAL or use errno, etc.
Code:
#include <iostream>
#include <cstdlib>
using namespace std;
const int MAX = 1000;
int main()
{
char input[MAX];
char *p;
double result;
bool invalid = true;
while(invalid)
{
cout << "Please enter a number : ";
cin >> input;
result = strtod(input, &p);
//if user pushed the enter key before other input, input is invalid
//if value of p is newline char or null char then all char entered by user were valid.
if(input[0] != '\n' && (*p == '\n' || *p == '\0'))
{
cout << result << " is valid input" << endl;
invalid = false;
}
else
cout << "Invalid input." << endl;
}
cout << endl;
char ch;
cin >> ch;
return 0;
}
Note: I assume you know that if the input in the GUI isn't in the form of a Cstyle string, you will need to convert it to a C style string in order to use strtod().