Use console cout to output debugging information in MFC programs

method:

Take the MFC dialog program as an example, add the following two lines of code to the OnInitDialog() function:

AllocConsole();  //控制台调试窗口开启
freopen("CONOUT$", "w", stdout);  //开启控制台输出支持

Error message:

Severity Code Description Project File Line Suppression Status
Error C4996 'freopen': This function or variable may be unsafe. Consider using freopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.     

Solution:

 Project--"Properties--"Configuration Properties--"C/C++--"Preprocessor--"Preprocessor Definition--"Add: _CRT_SECURE_NO_WARNINGS

 Output result:

Guess you like

Origin blog.csdn.net/stq054188/article/details/124049274
Recommended