I got this error when I used names to print the strings, but no errors when tempNames is used.
char* names[] = { "JIM",
"RAM",
"SAM",
0 };
int main(int argc, char *argv[])
{
char** tempNames = names ;
while(*names != 0)
std::cout << *names++ << std::endl ;
return 0;
}
How come *names became an rvalue whereas *tempNames is an lvalue.
As Bill Lynch explains in the comments you're incrementing type
char* []that's not allowed. (It's easier if you think of it as typeint [].) When you assign to achar**then you can increment it.Or a better C++ iterator based solution C++11: