Order:
I chose C + + primer as a classic in order to re-learn the C + + again in depth. This series of essays has been opened to record some interesting questions and experiences in the learning process. At the same time, also want to write essays in the way to urge themselves to continue to progress, to become a proficient in C + + programming skills and programming ideas Good Program Ape O (∩_∩) o well!
Body:
These two days will be C + + primer The first chapter of the time to read, reading process, encountered several interesting questions, worth recording:
one, compile your own C or CPP with the Windows command line
There are a lot of tutorials on this issue on the web, which are summarized and similar. Although the different vs (VC) versions have different details, take vs2010 as an example, in the following steps:
1. Add the/vc/bin of VS 2010 to the path
2.cmd Boot
3.vcvars32.bat setting up the environment for using the VS2010 X86 tool
4.CL/EHSC XXXX.cpp Compilation (direct CL also)
5. Call XXXX.exe directly to run
A bunch of online tutorials, but I ran into several interesting questions:
1. At first I used vs2015, but there is no cl.exe program in vs2015/vc/bin, so the above method does not apply. I have to tinker with long time also did not find a solution to the method, finally give up vs2015, using the vs2010.
2. During the operation, there is an interesting error: when typing CL compilation (or Lib) in Cmd, there is a case where mspdb100.dll cannot be found. Originally this is because vc\bin\ under no Mspdb100.dll "This file, directly from common7\ide\ under Copy this file to Vc\bin\ can.
second, how to observe the error ID returned by main
The Windows 7 operating system does not process or report the error ID returned by the program, intuitively, the program that returns 1 and the program that returns 0 does not differ in the execution effect. One possible way to see this is to have an echo%errorlevel% command immediately after the console window finishes executing the program. (ERRORLEVEL records the return value of the previous program)
Three, the difference between Cerr, cout and Clog
The 1.cout output information can be redirected, and the cerr can only be output to the standard output (monitor).
2.cerr does not pass through the buffer, directly to the monitor output information, and cout and clog information in the buffer, buffer full or encountered Endl output.
Both 3.cerr and clog are associated to standard errors, but cerr typically write to the same device as the standard output, and clog is typically written to a log file.
4.cerr is typically used to output error messages or other output content that is not part of normal logic, and clog is typically used to report execution information for a program.
Iv. file Terminator
The file terminator in Windows is ctrl+d in Ctrl+z,unix, and then press ENTER or return.
v. Buffer zone
I/O usually saves input and output data in a buffer, and the action of Read and write buffers is independent of the action in the program. By default, read CIN refreshes cout, and cout is refreshed when the program terminates abnormally.
C++primer Study notes (1)