Created
February 1, 2024 11:08
-
-
Save HotoRas/b4fa47dffcee052b1a6f2189d8cb065c to your computer and use it in GitHub Desktop.
Argument logger
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> | |
#include <fstream> | |
int main(int argc, char* argv[]) { | |
std::string file = "args.log"; // log file path | |
std::ofstream stream(file.data()); // out file stream: fstream as write mode | |
if (stream.is_open()) { | |
for (int i = 0; i < argc; i++) // arguments count at argc, so log it all with file name in argv[0] | |
stream << argv[i] << std::endl; // write args into file | |
stream.close(); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment