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

Null pointer assignmnet error

P: 34
Hello!

i wanna know about the illfamos null pointer assignmnet error..when can we face such an error and how do we debug it??
Jun 12 '07 #1
Share this Question
Share on Google+
5 Replies


RedSon
Expert 5K+
P: 5,000
Hello!

i wanna know about the illfamos null pointer assignmnet error..when can we face such an error and how do we debug it??
You make sure that your pointer is pointing to something that you can assign. If you try to assign something to NULL it gets NULL. If you are trying to assign a NULL pointer to something then you should not have a problem.
Jun 12 '07 #2

weaknessforcats
Expert Mod 5K+
P: 9,197
Use an assert.

At the desired place in the code assert that the pointer is not null. If it is, the code will break at the assert during execution.
Jun 13 '07 #3

P: 34
You make sure that your pointer is pointing to something that you can assign. If you try to assign something to NULL it gets NULL. If you are trying to assign a NULL pointer to something then you should not have a problem.

Im still not clear about the concept behind the error..I wanna know why this error occurs and how can we debug it??
Jun 13 '07 #4

weaknessforcats
Expert Mod 5K+
P: 9,197
Im still not clear about the concept behind the error..I wanna know why this error occurs and how can we debug it??
This is the same error as being told to go to a particular address in your city for a party but the piece of paper (the pointer) that has the address of the party is blank.

Generally, you do not debug null pointers. Instead, you test pointers for null before using them. A non-zero value in a pointer is assumed valid.

Use those asserts.
Jun 13 '07 #5

RedSon
Expert 5K+
P: 5,000
Im still not clear about the concept behind the error..I wanna know why this error occurs and how can we debug it??
It's not an error to debug. If you want to avoid having null pointer errors make sure that your pointers are not null, its very simple. You should be careful that your pointers do not point to random space in memory that could be very bad and is a common beginner programming mistake.
Jun 13 '07 #6

Post your reply

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