Without doing any testing I'm going to have a stab and say that a string like "somewhat" is not a char * but it is a const char * and therefore is not caught by your catch(char *) statement.
Try it with catch (const char*) and let me know.
BlakJak :]
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello forum,
I've tried this Code:
//...
try
{
//somewhat happens
if(somewhat has happened) throw "somewhat";
}
catch(char *str)
{
printf("%s has happened!!", str);
}
catch(...)
{
printf("Exeption not of type char* !!");
}
The strange thing is, that catch(char *str) is not executed, but catch(...).
If i would have written:
//...
char *ThrowStr = "TextTextText";
throw ThrowStr;
//...
, then catch(char *str) would have been tested.
In some Tutorials they write only the first syntax.
But why doesn't it work on my Dev-C++4 ???
Thanks , Tom.
Without doing any testing I'm going to have a stab and say that a string like "somewhat" is not a char * but it is a const char * and therefore is not caught by your catch(char *) statement.
Try it with catch (const char*) and let me know.
BlakJak :]
Thanks, BlakJak ;]
It really works!
Tom 8)