Question : C++ Command Line Args

I need a code snippet that can take a command line argument in C++.

I'm using MFC console Visual Studio 2008 so if there's a lib that can do it that would be great.

Command line looks like this.

program.exe -x c:\windows\program

Need to get the c:\windows\program string into my the C++ pogram as a CString.

Answer : C++ Command Line Args

For completeness, the simplest option;

1:
2:
3:
4:
5:
6:
7:
8:
9:
void main(int argc, char *argv[] )
{
    CString sFileParm;
    if ( argc > 2 ) {
        if ( CString(argv[1]) == "-x" ) {
            sFileParm= argv[2];
        }
    }
}
Random Solutions  
 
programming4us programming4us