-4

I'm using this code to test the entry from the command line when executing the program .. It's not working. What should I do ???? ?

if(argc >1)
    {
        if (argv[1]  == "b" || argv[1]  == "B")
                {b =1;}
        else if (argv[1]  == "h" || argv[1]  == "H")
                { b = 0;}
    }
    else 
        { b =0; }
joseph
  • 353
  • 3
  • 6
  • 10

1 Answers1

2

You can not compare c strings using == operator. Use strcmp instead. For example -

if ( (0 == strcmp(argv[1], "b") ||  .... )
Mahesh
  • 34,573
  • 20
  • 89
  • 115