By running Windows command-line compiler C language source file

By running Windows command-line compiler C language source file


1. Check the C language compiler environment is configured successfully
  • win + r input cmd open dos window, enter the command gcc -vto see if there is content output

    • If you have the following output, the configuration was successful, the next step can be carried out

    • If you enter this command, the following output dos window 'g++' 不是内部或外部命令,也不是可运行的程序或批处理文件。then the configuration fails compilation environment, needs to be reconfigured

    • Specific configuration environment variable can refer to the jdk environment variable configuration process, links to articles , the difference between them is the need to download something different, here to download content for mingW, additional configuration steps are pretty much the same


  1. New C language source file

    • File name helloWorld.c, note the name suffix is ​​.c

    • Code source file is

      #include <stdio.h>
      int main()
      {
      	printf("Hello World!");
      	return 0;
      }
      

  2. Compile and execute source file

    • Compilation (actually compiled C language program is divided into several stages, convenience, here referred to as the compiler)

      • Enter the following command gcc helloWorld.cto compile the source files, after compiling we will find the source files in the folder where the file helloWorld.c will produce a file named a.exe, the result is after the file compiled

    • run

      • We can directly enter ato run the program.



Guess you like

Origin www.cnblogs.com/TomHe789/p/12548649.html