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

  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...

12 Years
Discussion Span
Last Post by db0

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 :) ...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.