I have this program
I’d like to amend it to use getCommandLine()
Just, after the While loop, to print what getCommandLine() returns.
I don’t know C, though I do know programming..
How can I use getCommandLine?
I know logically, getCommandLine is a Windows thing, and I have to import something, but can anybody answer with code that actually does it?
If it makes any difference, i’m compiling it with TCC(Tiny C Compiler)
#include <stdio.h>
int main(int argc, char *argv[]) {
int i = 0;
while (argv[i]) {
printf("argv[%d] = %s\n", i, argv[i]);
i++;
}
return 0;
}
As documented here:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683156(v=vs.85).aspx
You’ll need to include
<windows.h>. But I don’t think it does what you think it does. It just gives you the full command line string, in the case that you don’t have argv/argc.Also you might find this post helpful:
Canonical way to parse the command line into arguments in plain C Windows API