Skip to main content
GameDev.net gamedev.net
🔒 Locked

Visual C++ command line options

Started by Blue*Omega Jun 24, 2001 at 9:07 PM 3 replies 400+ views
Original Post
Blue*Omega
Blue*Omega
Okay, I''ve been busting my brain trying to get this to work. I have a simple (dos) compression program that i have written and i want to add some command line options. Like so: Zipper -c test.zpp pic1.jpg pic2.jpg pic3.jpg Zipper is the program name, I want the -c to signal the progam to run the compile code (-e would be extract), the test.zpp the file i write to, and the rest to be the files I''m zipping. The thing I''m really stuck on is the -c though. How?!? I''m working in visual c++ 6.0; ----------------------------- Vash the Stampede "Love & Peace!"
Martee
Martee
Your entry point probably looks something like this:
int main(int argc, char* argv[])
argc is the number of command line arguments (including the program's name), and argv is an array of the arguments themselves. So to see if the '-c' flag is present, you could do something like this:
    
int main(int argc, char* argv[])
{
if(argc == 1)
call_some_error_routine();


if(!strcmp(argv[1], "-c"))
do_compile_stuff();

else if(!strcmp(argv[1], "-e"))
do_extract_stuff();

...
}


~~~~~~~~~~
Martee

Edited by - Martee on June 24, 2001 10:14:44 PM
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
bishop_pass
bishop_pass
For anyone reading this: Please NEVER refer to a feature of the C or C++ language as a feature of Visual C++. Microsoft does not have a monopoly on the functionality of C or C++. The features being asked about here were in existence before Microsoft existed.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in
Blue*Omega
Blue*Omega
Thanks! I was trying:

if(strcmp(argv[0],"-c"))
{
compile();
}

BTW: I knew that this feature was in place before microsoft barged in. I just wondered if there might be a difference between it and other compilers (shouldn''t be...)

-----------------------------

Vash the Stampede

"Love & Peace!"
Null and Void
Null and Void
quote:
Original post by bishop_pass
For anyone reading this: Please NEVER refer to a feature of the C or C++ language as a feature of Visual C++. Microsoft does not have a monopoly on the functionality of C or C++. The features being asked about here were in existence before Microsoft existed.

That''s exactly what I''m thinking anytime someone mentions "the next version of C++" or "learning Visual C++" .

[Resist Windows XP''s Invasive Production Activation Technology!]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.