c++
-
stl::map에서 updateComputer/Programming 2011. 6. 29. 10:45
stl::map에 에서 이미 존재하는 항목을 update하기 위해서는 다음과 같이 사용한다. #include #include void main() { std::map test1; test1[0] = 1; test1[1] = 2; test1[1] = 3; for (auto it = test1.begin(); it != test1.end(); it++) { printf("%d %d\n", it->first, it->second); } } 배열에 값을 할당하듯 사용하면 해당되는 key 값이 없으면 map에 새로 추가되고, 해당되는 key 값이 없으면 map에 있는 해당 항목 값이 변경된다. 그런데 stl::map 구조를 pointer로 선언했을 때는 배열 사용하듯 할 수가 없고 값의 변경을 위한 함수가 따로 ..
-
visual c++ 에서 std::string에서 formatted string을 찍어주기 위한 코드Computer/Programming 2011. 6. 21. 18:22
formatstdsting.h #include #include std::string format(const char *fmt, ...); std::string format_arg_list(const char *fmt, va_list args); formatstdstring.cpp #include "formatstdstring.h" #pragma warning(disable:4996) std::string format(const char *fmt, ...) { va_list args; va_start(args, fmt); std::string s = format_arg_list(fmt, args); va_end(args); return s; } std::string format_arg_list(const ..
-
A Simple Python Wrapper to Undecorate Visual Studio Linker Symbol NamesComputer/Programming 2008. 9. 24. 17:30
While writing a Windows binary program analyzer, I needed a name unmangler which returns a function name and its namespace. Since I am writing the program analyzer with Python and C++, I first tried to find a python name unmangler. But so far, there is no python unmangler. There was a discussion about the need of the python unmangler script at OpenRCE. Anyway, I planed to write a C function that..
-
Elsa - C++ Parser makeComputer/Programming 2008. 9. 18. 16:23
Elsa is downloaded from http://www.cs.berkeley.edu/~smcpeak/elkhound/sources/elsa/ . Cygwin was installed before. Flex 2.5.35 is installed via cygwin setup program. I met a few problems while building the elsa package. The first problem was a sort of preprocessor syntax error. I found the following code snippet. /* The contents of this function are C++ specific, so the () macro is not used. The ..