I am reading data from text file and there is double value which i need to read from the file. Now the problem is that if the double value is invalid for example “!@#$%^&*” then i want my program to give exception so i can handle it. This is my code
void Employee::read(istream &is) {
try{
is.get(name, 30);
is >> salary;
char c;
while(is.peek()=='\n')
is.get( c );
}
catch(exception e){
}
}
I finally made it work by setting exception bit on for istream