I have written this code in C++ in the CodeBlocks IDE but when I run it, it doesn't give me -1 if it doesn't read a number, it gives me 0. Is there something wrong with the code?
#include "iostream"
using namespace std;
int main()
{
cout<<"Please enter your first name and age:\n";
string first_name="???"; //string variable
//("???" means "don't know the name")
int age=-1; //integer variable (-1 means "don't know the age")
cin>>first_name>>age; //read a string followed by an integer
cout<<"Hello, " <<first_name<<" (age "<<age<<")\n";
return 0;
}