I am making this assignment in my program and I am getting the warning a titled. Here is the code snippet:
table_name[index] = NULL;
I could not understand what can be a problem in such a statement.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
NULL is not a valid integer, and it is being assigned to an entry of an array made up of presumably
ints, so the compiler is complaining.NULL is used as a default pointer value that indicates “nothing” .. if you had a pointer variable and assigned NULL to it, you’d be saying that pointer variable points to “nothing”.
Because of this type mismatch, the specific message is warning you that you are trying to assign one type (really a pointer value) to another (
int) without trying to cast it (which is how we sometimes convert one type to another in order to avoid type mismatches).If you had an array of pointers this assignment of NULL would be perfectly ok.