0

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:

  1. open cmd
  2. $ gcc -o testprog.exe main.c -lWs2_32
  3. $ 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?

jwdonahue
  • 6,199
  • 2
  • 21
  • 43
Wizard
  • 1,533
  • 4
  • 19
  • 32

0 Answers0