How to use memcpy example

The memcpy function is declared in stdlib.h. It accepts three arguments: the destination ... position. Here is the example code: #include <stdlib.h> #include <stdio.h> #include ... ** argv) { int buf[1024]; buf[1] = 0xffffffff; char * s = "bazzar"; //memcpy ... (buf, s, strlen(s)); memcpy(buf, s, strlen(s) + 1); printf("buf is %s", buf); printf("\n

How to use data breakpoint in Visual Studio

Data breakpoint is a breakpoint that be triggered when the content of a specified memory location is modified.

In a complex program, to find where and when a specific variable was modified may be difficult.

Log text to file with log4cpp

First step is download source code from github.

If you are using Visual Studio 10, after update the solution file, modify log4cppLIB.vcxproj like this.

Some const examples in C++

The const modifier is always a confusing keyword. Here are some of them.

They are equivalent, the const modifies the left element, if the const has no left element, means the const is the first key word, then it modifies the right element.

How to use assignment operator

The assignment operator and copy constructor often confuse people. Here is an example.

If you create new object from old object like this.

How to use inline in C++

If you define your member function inside class declaration , they are implicitly inline.

The inline function is supposed to improve the performance by embedding the function body to calling place and so reduce calling cost. It has two disadvantages: add the size of the program and change of the inline function will make caller recompile.

C++ enum example and tutorial

enum(enumeration) is a user-defined type consisting of a set of enumerators( enumerator --- named integer constant)

Simple enum definition:

An Introduction of the C++ Standard Template Library

The C++ STL(Standard Template Library) is a carefully constructed library developed by Alexander Stepanov, Meng Lee and others at Hwelett Packard.

The core of STL include container which represent data structure and algorithm which apply on the data structure and iterator which is the bridge between container and algorightm.

An Simple Example Help You Understand STL

This example comes from the book of "Addison-Wesley, Designing Components with the C++ STL, Electronic 3rd Edition.pdf". Its a simple list implements an iterator in the class.

Look at each function carefully and get a clear idea of the mechnnism you will understand the core of the STL.