c++: truth assignment warning with arguments?
- by John
I use the following to work with arguments in my programs, but it seems to just hand me a warning (just a warning): "warning: suggest parentheses around assignment used as truth value"
The beginning of the code is as follows:
enum{OPT_DISP_H = 0x2, OPT_DISP_W = 0x1};
int main(int argc, char *argv[])
{
int opt = 0x00;
char c;
while((++argv)[0] && argv[0][0]=='-'){
while(c =* ++argv[0])
switch(c){
case 'h':
opt |= OPT_DISP_H;
break;
//etc..
The while(c =* ++argv[0]) part being where the warning persists. The code works fine, but what does this warning mean opposed to what is used?
I think the code is c = *++argv[0], using the pointer. So why does the single = work and what is really recommended to be used?