mardi 26 décembre 2017

Can you compared a Variable to a Data Type?

int user_choice;
cout << "Enter a number from 1-10: ";
cin >> user_choice;

if (user_choice == int)//int being a data type
   cout << "Is an integer";

else
  if (user_choice == char)// char being a data type
      cout << "Is a character";

Can something like this be done? and how?

Aucun commentaire:

Enregistrer un commentaire