Memory leak 잡기

_CrtSetDbgFlag와 _CrtSetBreakAlloc를 사용하여
메모리 릭이 나는 곳의 번호…를 적어주면

예를 들어.. Detected memory leaks! Dumping objects -> {10439} normal block at 0x07250BE0, 4 bytes long.  Data: <    > 00 00 00 00 Object dump complete.
실행후 이런 에러가 났다면…

_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); 
_CrtSetBreakAlloc(10439);

이렇게 하면 10439메모리 블럭에서 브레이크가 걸린다!!!

카테고리: 분류되지 않음 | 댓글 남기기

화일 이동, 복사, 삭제 등등

CAtlTransactionManager Class

http://msdn.microsoft.com/ko-kr/library/dd795992.aspx

카테고리: MFC | 댓글 남기기

rand 함수

// crt_rand.c
// This program seeds the random-number generator
// with the time, then displays 10 random integers.
//

#include <stdlib.h>
#include <stdio.h>
#include <time.h>

int main( void )
{
   int i;
  
   // Seed the random-number generator with current time so that
   // the numbers will be different every time we run.
   //
   srand( (unsigned)time( NULL ) );

   // Display 10 numbers.
   for( i = 0;   i < 10;i++ )
      printf( ”  %6d\n”, rand() );

  printf(“\n”);

  // Usually, you will want to generate a number in a specific range,
  // such as 0 to 100, like this:
  {
     int RANGE_MIN = 0;
     int RANGE_MAX = 100;
     for (i = 0;    i < 10; i++ )
      {
         int rand100 = (((double) rand() /
                         (double) RAND_MAX) * RANGE_MAX + RANGE_MIN);
         printf( ”  %6d\n”, rand100);
      }
  }
}

카테고리: C/C++/STL 등등 | 댓글 남기기

안녕하세요!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

카테고리: 분류되지 않음 | 1개의 댓글

두 점의 각도를 구하는 식

점 A(x1, y1), B(x2,y2)가 있을 때 두 점의 각도를 구하려면…
 180 * atan2(x2-,x1, y2-y1)/PI 하면 됩니다..
 참 각도의 방향은 아래의 그림과 같습니다.~

카테고리: 영상처리 | 댓글 남기기

PeekMessage vs GetMessage

PeekMessage는 입력이 있으면 무조건 참이고
GetMeesage는 WM_QUIT메세지도 거짓으로 판담
카테고리: MFC | 댓글 남기기

OpenCV 영상 상하 반전

cv::flip 함수가 있음

void flip(const Mat& src, Mat& dst, int flipCode);
세 번째 인자가 0이면 x축 반전, 양수면 y축 반전, 음수면 x축, y축 둘다 반전

카테고리: 영상처리 | 댓글 남기기

Unicode 상에서 CString을 std:string을 바꾸기

CString a = "ASDF";
 std::string filename;
 filename = CW2A(a);
 
 
카테고리: MFC | 댓글 남기기

Relationsship between char, wchar_t and TCHAR

 
  • char: 8bit
    wchar_t: 16-bit
    TCHAR: char in MBCS build, wchar_t in Unicode build
  • LPSTR: char*
    LPWSTR: wchar_t*
    LPTSTR: TCHAR*
  • LPCSTR: const char*
    LPCWSTR: const wchar_t*
    LPCTSTR: const TCHAR*
카테고리: MFC | 댓글 남기기

MFC에서 Commandline 인자를 받는 법..

 CString strArg[5];
 int iNumberOfArgs;
 LPWSTR *aa;
 LPWSTR a = ::GetCommandLineW();
 aa = CommandLineToArgvW(a, &iNumberOfArgs);
이러면… aa배열에 저장된다.. ㅎㅎ
카테고리: MFC | 댓글 남기기