#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main()
{
int num;
while(1){
cin>>num;
cout<<num<<endl;
}
return 0;
}
When I try to run this code, it outputs value of 'num' everytime I input an int. But when I type a string or char for input,it stops asking for input from the next iteration and starts outputting 0 in an infinite loop. Can anyone explain reason behind this?