Created
June 19, 2019 14:55
-
-
Save Steffo99/abe422b9e4520480af3d5e1ab35032d3 to your computer and use it in GitHub Desktop.
Come funzionano argc e argv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| int main(int argc, char *argv[]) { | |
| /* argc è il numero di parametri passati | |
| * argv è un array di stringhe lungo [argc] contenente i parametri passati | |
| * | |
| * Il primo parametro passato è sempre il nome del file. | |
| * | |
| * ./a.exe uno due tre | |
| * argv[0] = "./a.exe" | |
| * argv[1] = "uno" | |
| * argv[2] = "due" | |
| * argv[3] = "tre" | |
| */ | |
| //Stampa tutti gli argv | |
| for(int i = 0; i < argc; i++) { | |
| std::cout << "argv[" << i << "] = \"" << argv[i] << "\"\n"; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment