background preloader


Facebook Twitter

Is not available. C++ Design Pattern: What is a Design Pattern? Memory Snapshot for a Process. In-depth memory layout is specific to both the CPU architecture and the OS itself. I'm going to describe how a process sees its own memory share during execution. Memory Layout from a process perspective When a program is executed it is read into memory* where it resides until termination. The code allocates a number of special purpose memory blocks for different data types. A very common scheme, but not the only one, is depicted in the following table. In order to prove that things work this way (on many systems anyway) I wrote a C program, mem_sequence.c, that allocates 5 types of data, finds their location the (virtual) memory address, sorts them in descending order and then displays presenting a similar output to the table above. mem_sequence.c is tested on Linux, FreeBSD, MacOS X, WinXP and DOS.

This is how you use mem_sequence: $ gcc mem_sequence.c -o mem_sequence$ . Let's analyze it:The code (5) and constants (4) fall into the readable and executable (non-writable!) 100 C Interview Questions & C FAQs. Tree traversal. Types[edit] Pre-order: F, B, A, D, C, E, G, I, H In-order: A, B, C, D, E, F, G, H, I Post-order: A, C, E, D, B, H, I, G, F Level-order: F, B, G, A, D, I, C, E, H Compared to linear data structures like linked lists and one-dimensional arrays, which have a canonical method of traversal (namely in linear order), tree structures can be traversed in many different ways.

Tree traversal

The name given to a particular style of traversal comes from the order in which nodes are visited. For the purpose of illustration, it is assumed that left nodes always have priority over right nodes. Depth-first traversal is easily implemented via a stack, including recursively (via the call stack), while breadth-first traversal is easily implemented via a queue, including corecursively. Beyond these basic traversals, various more complex or hybrid schemes are possible, such as depth-limited searches such as iterative deepening depth-first search. Depth-first[edit] Pre-order[edit] In-order (symmetric)[edit] Post-order[edit] C++ casting operators. Converts between types using a combination of explicit and implicit conversions.

C++ casting operators

[edit] Syntax Returns a value of type new_type. [edit] Explanation 1) When the C-style cast expression is encountered, the compiler attempts the following cast expressions, in this order:


Showthread. Complex Function pointers. Floating Point Numbers. By Jeff Bezanson Numbers are surely the most prevalent kind of data in computer programs.

Floating Point Numbers

They are so fundamental that people don't spend much time talking about them—surely everybody knows how to use numbers in their programs. Well, one of the wonderful things about programming is that nearly everywhere you look, you find more than meets the eye. Most programmers have heard or observed one strange thing or another about floating point numbers.

For example, we often discover that floating point numbers that look the same do not necessarily satisfy C's "==" test. What is going on? Floating point numbers provide a kind of illusion; they look like "real" numbers, with decimals and possibly very large or small magnitudes. Accuracy and precision are two concepts in measurement that nicely capture the different properties of ints and floats (on any system, independent of the particular floating point representation used). Now how can I make an outlandish claim like that?

Debbugger Writing