Hi all. Somthing strange is going on... I want to use "-debug" command line parameter to make my app show some debug info. Here is my code (not entire but needed part)...

#include <iostream.h>

bool debug_mode=0;

int main(int argc, char **argv)
{

if(argv>1) cout << argv[0] << endl << argv[1] << endl;

if( (argc>1) && (argv[1]=="-debug") ) debug_mode=1;

// Some code that checks my database integrity, and does not use
// debug_mode variable in any way

if(debug_mode)
{
  cout << "Some debug information" << endl;
}

// here is additional code

return 0;

}

The problem is that when I start my app with "-debug" (exactly "./dbreader -debug") parameter I can see that my argv[0] is "./dbreader" and argv[1] is exactly "-debug" but my IF STATMENT didn't set debug_mode to "1", and so no additional info is shown...

I have already solved my problem... I had to use "strcmp" function instead of "==" operator to compare argv[1] with "-debug" string....
I think i have to sleep a little more than 3-4 hours to make my brains work better :) ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.