I am getting an error described in the title when I try to run my code with this line:
(int**)newPtr = *(list + index);
Does anyone know whats wrong?
These are my declarations
int index;
int* newPtr;
static int* list;
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.
There are a couple of errors in the code:
newPtr is declared as a pointer-to-integer, but you are casting it to pointer-to-pointer-to-integer which is wrong.
list+index is also a pointer-to-integer to *(list+index) is an integer pointed to by (list+index). But you are trying to assign that to newPtr (which is also casted to wrong type as above).
Possibly you intended to do this:
and get a pointer-to-integer located at list + index-th location.