| | |
Using command line parameters
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2004
Posts: 3
Reputation:
Solved Threads: 0
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)...
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...
C++ Syntax (Toggle Plain Text)
#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...
![]() |
Similar Threads
- command line parameters part 2! (VB.NET)
- Command line parameters (VB.NET)
- command line string swap (C)
- Preprocessor definitions on the command line (C++)
- command line arguments help (C)
- Windows Main and Command Line Parameters (C)
Other Threads in the C++ Forum
- Previous Thread: Graphics In Pixel: Part II
- Next Thread: Polygon Program
| Thread Tools | Search this Thread |
api array based binary bitmap c++ c/c++ calculator char char* class classes code coding compile console conversion database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






...