468,512 Members | 1,406 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

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

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
1 12416
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.

Similar topics

5 posts views Thread by Tony Cheng | last post: by
3 posts views Thread by chramprasad | last post: by
1 post views Thread by bansalrichaacc | last post: by
5 posts views Thread by iamdennisthomas | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.