_CrtDumpMemoryLeaks memory leaks in the reporting program (simple sample Code)

Source: Internet
Author: User

//. h file#pragmaOnceclassCconsoledump { Public:      ExplicitCconsoledump (LPCTSTR lpszwindowtitle =NULL); Virtual~cconsoledump (void);  Public: BOOL DUMP (LPCTSTR lpszfmt, ...);      BOOL ShowWindow (bool Bshowwindow); BOOL SetWindowText (LPCTSTR lpszwindowtitle=NULL);    }; //. cpp Files#include"StdAfx.h"#include"ConsoleDump.h"    #defineMax_buffer_size (10 * 1024)cconsoledump::cconsoledump (LPCTSTR lpszwindowtitle) {if(AllocConsole ()) {if(NULL! =lpszwindowtitle)          {Setconsoletitle (lpszwindowtitle); }}} Cconsoledump::~cconsoledump (void) {freeconsole (); } bool Cconsoledump::showwindow (bool Bshowwindow) {return:: ShowWindow (Getconsolewindow (), Bshowwindow?sw_show:sw_hide); } BOOL SetWindowText (LPCTSTR lpszwindowtitle) {if(NULL! =lpszwindowtitle) {          returnSetconsoletitle (Lpszwindowtitle); }      returnTRUE;  } BOOL Cconsoledump::D UMP (LPCTSTR lpszfmt, ...) {TCHAR Sztext[max_buffer_size]= {0};      Va_list arglist;      Va_start (arglist, lpszfmt);      _vstprintf_s (Sztext, _countof (Sztext), lpszfmt, arglist);        Va_end (arglist); returnWriteconsole (GetStdHandle (Std_output_handle), Sztext, _tcslen (sztext), NULL, NULL); }    //Test UsingCconsoledump M_dump;//A member variable defined as a class//where needed to use Cconsoledump::D UMP function output log information can beM_dump. DUMP (_t ("Hello, world!\r\n."));

This is just a simple package of several functions related to the console, for more console-related controls, you can refer to the MSDN documentation

Reference: http://blog.csdn.net/visualeleven/article/details/7628564

_CrtDumpMemoryLeaks memory leaks in the reporting program (simple sample Code)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.