By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,313 Members | 1,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,313 IT Pros & Developers. It's quick & easy.

How to catch and log NULL pointer exception in C++

P: 22
Hi All,

Plz help me if you can.....

I have a program something like this
int main(int argc,char* argv[])
{
try
{
int* p = NULL;
int i = *p;
}
catch(int* ptr)
{
cout<<"Caught Null pointer Exception\n";
}
catch(...)
{
cout<<"Caught an Exception\n";
}
return 0;
}
Result of this program is
"Caught an Exception"
But i was expecting "Caught Null pointer Exception"

Now plz tell me how to know in which line exception occured and which exception occured

Eagerly waithig for your reply..........
Sep 10 '06 #1
Share this Question
Share on Google+
1 Reply


P: 1
I am using the method described here: http://www.codeproject.com/KB/cpp/exceptionlogging.aspx
Aug 16 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.