[C / C ]Check the input string can be zero in C – Check string import is number in C

There are many checks but here we use the function cin.fail()

#include <iostream>
using namespace std;
int main()
{
    double a;
    cout<<"nHay nhap vao ki tu a";
    cin>>a;
    if(cin.fail())
        cout<<"n Bi loi roi";
    else
        cout<<"nSo vua nhap vao la: "<<a; 
	return 0;
}

Also can be used:

string line;
    getline(cin,line);
    if (atof(line.c_str()) || line == "0") cout<<endl<<atof(line.c_str()); 
    else cout<<"loi";