dimanche 3 mai 2020

The cerr is not printing what is stated but rather is printing something else related to error? [duplicate]

#include"std_lib_facilities.h"
int main()
try{
  int x = 0;
  int y = 1;
  int d = y/x;
  return 0;
}
catch(...){
  cerr<<"there is an error\n";
  return 1;
}

I am just learning how to use the try and catch so that i could define an error to the user but after writing the code, compiler is printing something else but related to error.I am not getting promising results in google.Just tell me where is the problem!

output:

Floating point Exception(core dumped)

Aucun commentaire:

Enregistrer un commentaire