Http://jingyan.baidu.com/article/4853e1e5787d6b1909f726f8.html
Configure the MINGW environment in your computer.
See my other share experience--MINGW configuration in a Windows environment:
Http://jingyan.baidu.com/article/6b97984da0bd8a1ca2b0bf90.html
- 2
Open a command-line prompt.
See my other sharing experience--windows how to open a command line prompt in the environment:
Http://jingyan.baidu.com/article/0320e2c1cf260c1b86507b4d.html
- 3
Switch the path to the directory where C + + source code resides.
- 4
View the C language source code.
The source code is as follows:
#include <stdio.h>
int main ()
{
printf ("Hello world!\n");
return 0;
}
- 5
The source code must finally have a blank line in the previous step, or the warning will be reported at compile time. This is because the compiler requires that the file end with a carriage return as the end of the file. Because the end of the line is connected to the next line, if the last line of a file (the right brace of the main function) has a/at the end of the line, then the first line of the next source file that immediately follows it is also connected, and if a file ends with a blank line, it avoids the occurrence.
- 6
Compile the C language source code.
Command format: GCC xxx.c-o xxx.exe
Note: The above command can also add parameter options, for example:
Gcc-g-wall Xxx.c-o Xxx.exe
- 7
Run the C program.
Command format: Xxx.exe (or remove the suffix name, directly using XXX)
END
Method 2:c++
Compile C + + source code.
Command format: g++ xxx.c-o Xxx.exe
Note: The above command can also add parameter options, for example:
g++-g-wall Xxx.c-o Xxx.exe
Run a C + + program.
Command format: Xxx.exe (or remove the suffix name, directly using XXX)
- 3
If the case is shown, refer to step 5th in Method 1 and add a blank line at the end of the source code.
MinGW to run C + + in a Windows environment with a command prompt