I have no idea what half of your code means, but here is your solution. I don’t understand why you have a while loop after main? Many other “Why’s?” , but here is the code:
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
int main()
{
string input = "";
int number = 0;
while (true)
{
cout << "Enter a float value: ";
getline(cin, input);
stringstream myStream(input);
if (myStream >> number)
{
system("CLS");
break;
}
system("CLS");
cout << "Invalid input! Try again" << endl << endl;
}
cout << "Float: " << input << endl << endl;
system("PAUSE");
return 0;
}
solved How to loop to get floating-point only? [duplicate]