문제

I am working on a project where a user enters different types of variables I'm trying to make my project fool proof so I'm trying to prevent a data mismatch. An example of the type of input that I'm asking the user for would be something like this:

int main(){
    int num;
    string name,name2;
    double money
    cout<<"Enter your first name:"<<endl;
    cin>>name;
    cout<<"Enter your last name"<<endl;
    cin>>name2;
    cout<<"Enter a number"<<endl;
    cin>>num;
    cout<<"Enter an amount of money you have"<<endl;
    cin>>money;
}

I'm main worried about the integer and double types of variables. So I'm wondering if there is a kind of exception for data mismatch for both integer and double variable types?

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top