I am wanting to compile c through the command prompt on Windows.
I have the following file main.c
:
#include <stdio.h>
#ifdef _WIN32
int main () {
printf("Windows\n");
return 0;
}
#else
int main () {
printf("*nix\n");
return 0;
}
#endif
And I follow these steps:
- open cmd
$ gcc -o testprog.exe main.c -lWs2_32
$ testprog.exe
Output is *nix
I have installed MinGW and setup the path to gcc
. I have also tried using __MINGW32__
. What do I need to do?