Expression must be modifiable lvalue - c++ Error [closed]

asked 2014-08-04 05:47:17 -0600

sabariaug23 gravatar image

I got the error when I execute the following code.

int *p;
p = (int *)malloc(128*sizeof(int *));
for (int i = 0; i < 128; i++)
{
    (*p + i) = 0;
}

Expression must be modifiable lvalue

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by berak
close date 2014-08-04 07:49:52.529679

Comments

Have you tried *(p+i) = 0 ? Anyway, try to use C++ stuff, like shared_ptr or unique_ptr, or weak_ptr instead of * and malloc; or for your case use std::vector. -1 because it's not a question linked to OpenCV

thdrksdfthmn gravatar imagethdrksdfthmn ( 2014-08-04 07:12:45 -0600 )edit