Implementation of "app.exe -instruction file" notation in C ++
I have a project for my Data Structures class, which is a file compressor that works using binary trees and other things. We are required to "zip" and "unpack" any file using the following commands on the command line:
For compression: compress.exe -zip file.whatever
To decompress: compress.exe -unzip file.zip
We program in C ++ . I am using IDE Code :: Blocks and compiling with GCC on Windows.
My question is: How do you even implement this? !! How can you get your .exe to get these parameters on the command line and then execute them the way you want?
Also, is there anything special in mind if I want this implementation to compile on Linux?
thanks for the help
a source to share
Lo logre, I got it!
I now have a basic understanding of how to use the argc and argv [] parameters in the main () function (I've always wondered what they were good for ...). For example, if I put on the command line:
compress.exe -unzip file.zip
Then:
- argc is initialized to '3' (number of arguments per line)
- argv [0] == "compressor.exe" (application name)
- argv [1] == "-unzip"
- argv [2] == "file.zip"
Greg (not 'Creg', sorry = P) and Bemrose, thank you guys for your help !! ^^
a source to share
You can look in your programming text for a function signature main
, your program entry point. That's where you will be able to use these command line parameters.
I donβt want to be more detailed than that, because this seems to be the key point of the assignment, and if I ever find myself with you, Iβll expect you to be able to understand this kind of thing when you get the nudge. :)
Good luck!
a source to share