Created
February 19, 2018 01:15
-
-
Save binki/d8be8a7eb90340d660582e0ba8caf08a to your computer and use it in GitHub Desktop.
Windows command line
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 <windows.h> | |
int main( | |
int argc, | |
const char *const argv[]) { | |
const HANDLE stdOutput = GetStdHandle(STD_OUTPUT_HANDLE); | |
if (stdOutput == INVALID_HANDLE_VALUE) { | |
return 1; | |
} | |
const LPSTR cmdLine = GetCommandLine(); | |
if (!WriteFile(stdOutput, cmdLine, lstrlenA(cmdLine), NULL, NULL)) { | |
return 1; | |
} | |
const char *nl = "\r\n"; | |
if (!WriteFile(stdOutput, nl, lstrlenA(nl), NULL, NULL)) { | |
return 1; | |
} | |
return 0; | |
} |
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
C:\Users\ohnob\repos\winmain-play>.\main This is a string that isn't quoted or anything | |
.\main This is a string that isn't quoted or anything | |
C:\Users\ohnob\repos\winmain-play>.\main "this is a string quoted ""using conventions""" | |
.\main "this is a string quoted ""using conventions""" | |
C:\Users\ohnob\repos\winmain-play>.\main --blah='asdflkj' | |
.\main --blah='asdflkj' | |
C:\Users\ohnob\repos\winmain-play>.\main --blah="asdflkj" | |
.\main --blah="asdflkj" | |
C:\Users\ohnob\repos\winmain-play>.\main "--blah="asdflkj" | |
.\main "--blah="asdflkj" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment