Last active
April 19, 2024 13:03
-
-
Save mhrstmnn/53613b9225afbaa9456556443e96d6f4 to your computer and use it in GitHub Desktop.
Simple method to output CLI arguments in C++
This file contains 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> | |
void printArgs(const int argc, const char *argv[]) | |
{ | |
std::cout << "argc: " << argc << "\n\n" | |
<< "argv:\n"; | |
for (unsigned int i{}; i < static_cast<unsigned int>(argc); ++i) | |
std::cout << "- " << argv[i] << '\n'; | |
} | |
int main(const int argc, const char *argv[]) | |
{ | |
printArgs(argc, argv); | |
return {}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment