Total Visits: 457300.
Totally 29 C/C++ Related Articles.

Font Inc/Dec:
Ctrl + Roll Down/Up
Same Virtual Member Function, Different Addresses (同一Virtual成员函数,不同地址)
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=109&getYearMonth=20102
- Last Update: Monday, Feb. 1, 2010
- Peter Lee's Comments: I have been trying to understand the address of a virtual member function, however, I found it's very tedious and difficult to fully understand it, and finally we may need a lot of compiler and assembly knowledge to find it out.
An Example Implementation of C++ Polymorphism - VTable with Memory Layout(一种C++多态的实现--内存分布的虚函数表)
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=107&getYearMonth=20101
- Last Update: Saturday, Jul. 24, 2010
- Peter Lee's Comments: A lot of programmers can use the C++ polymorphism well in their Object-Oriented programming, however, some of them might not know how it really works inside. Here, I'm trying to explain the memory layout of ONE example implementation of C++ polymorphism.
Transpose a Matrix (2-Dimension Array) Inplace (矩阵-2维数组原地转置)
Peter Lee's Collection of C++ FAQs and Skills (Peter Lee 的 C++ 常见问题和技巧集锦)
Implementation of ANSI C Non-String Library Functions (ANSI C 非字符串库函数的实现)
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=85&getYearMonth=200811
- Last Update: Monday, Apr. 6, 2009
- Peter Lee's Comments: If you wanna become an Embedded Software Enginner or Staff C Programmer, you must have some fundamental ideas on how the ANSI C library functions were implemented. Furthermore, some of these functions are very common in an C/C++ programmer interview, esp., strrev() (note: strrev() is not ANSI C standard) and strtok() as well as atoi() and itoa() (note: both of them are not ANSI C standard). I'm now trying to implment all of these non-string functions for your reference (see Implementation of ANSI C String Library Functions (ANSI C 字符串库函数的实现) for string library functions). Please debug them for me if possible.
Bit Operation "Set" And "Clear" (位操作的Set和Clear)
Implementation of ANSI C String Library Functions (ANSI C 字符串库函数的实现)
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=83&getYearMonth=200811
- Last Update: Monday, Jul. 5, 2010
- Peter Lee's Comments: If you wanna become an Embedded Software Enginner or Staff C Programmer, you must have some fundamental ideas on how the ANSI C string library functions were implemented. Furthermore, these functions are very common in an C/C++ programmer interview, esp., strrev() (note: strrev() is not ANSI C standard) and strtok(). I'm now trying to implment all of these string functions for your reference. Please debug them for me if possible.
Memory Allocation & Management For C Program (C程序的内存分配与管理)
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=82&getYearMonth=200811
- Last Update: Friday, Jan. 1, 2010
- Peter Lee's Comments: If you wanna become an Embedded Software Engineer or Staff C Programmer, you must have some fundamental ideas on how the memory is allocated and managed. I'm here trying to explain and describe it as a general concept, which is OS-Dependent.
Peter Lee's Collection of C FAQs and Skills (Peter Lee 的 C 常见问题和技巧集锦)
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=81&getYearMonth=200811
- Last Update: Monday, Apr. 6, 2009
- Peter Lee's Comments: As Peter Lee used to say "Being familiar with C language gives you the job; Mastering C++ makes job everywhere!", strong skills with C/C++ are very important as a Software Engineer/Developer. For sharing with others and for the purpose of my own, I've been collecting the questions and skills related with C/C++ programing languages.
Conversion Between Unicode-UCS-4 And UTF-8 (Unicode-UCS-4 与 UTF-8 之间的转换)
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=80&getYearMonth=200811
- Last Update: Saturday, Dec. 6, 2008
- Peter Lee's Comments: I'm kinda practising my C programming skills, and I found some friends had written some codes, but the codes might not be readable. I learned the rules of the conversion between Unicode and UTF-8, and wrote two functions as shown below.
A Simple Version Of QuickSort (快速排序的一个简单版本)
Dynamic Programming in Knapsack Problem (背包问题中的动态规划编程)
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=63&getYearMonth=20089
- Last Update: Saturday, Dec. 6, 2008
- Peter Lee's Comments: It took me so long time to understand the essence of dynamic programming skills in knapsack problem. Dynamic programming is very useful in Viterbi algorithm in speech recognition, so I have to master how it works.
How Multithread Program Works (多线程程序的工作原理)
Structure & Sample Extraction of Canonical WAVE PCM Audio File (标准WAVE PCM音频文件的结构和采样方法)
Hexadecimal Viewer for Arbitrary Files (任意文件的十六进制查看器)
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=44&getYearMonth=20085
- Last Update: Monday, Apr. 6, 2009
- Peter Lee's Comments: I've been studying the structure of a Wave PCM file, so I need a viewer to look into the wave file header or its trunks and data. I know Microsoft Visual C++ 6.0 (EXPENSIVE) has this functionality, but Visual C++ 2008 Expression Edition (FREE) does not. Therefore, I wrote a HexViewer for myself and share with you.
Ensure and Create a Directory (判断和创建目录)
Understanding the Variable Argument Lists <cstdarg> Functions (理解变参数<cstdarg>函数)
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=37&getYearMonth=20085
- Last Update: Monday, May. 12, 2008
- Peter Lee's Comments: During my 8 years' programming experience, I have never used this so-called user-defined Variable Argument Lists Functions. Of course, We've been using the C standard IO functions: printf(), scanf(), sprintf(), fprintf() and so on.
Memory Strcuture of 32-bit Floating Number (32位浮点数的内存结构)
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=36&getYearMonth=20085
- Last Update: Monday, Mar. 15, 2010
- Peter Lee's Comments: Once upon a time, I was so curious on how the floating numbers (such as, 1.F, 0.1F, 0.5F, -1234.56F and so on) are stored in the memory. Time always permitted me to do a detailed research into this, which was just an excuse. Therefore, I decided to insight into the 32-bit floating structure.
Throw/Catch Arithmetic Floating Number Over/Underflow (四则运算浮点数溢出的异常抛出与处理)
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=35&getYearMonth=20085
- Last Update: Sunday, May. 11, 2008
- Peter Lee's Comments: This is an exercise problem in §8.5.10 in The C++ Programming Language. I found it's a good one for getting familiar with float number over/underflow and exception throw/catch. Therefore, I just wanna keep the source code below as a good reference for myself in the future.
Example Code for setjmp.h (setjmp() & longjmp())
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=34&getYearMonth=20085
- Last Update: Friday, May. 9, 2008
- Peter Lee's Comments: I found a lot of text books cannot explain the C/C++ language so well due to lacking of vivid or understandable examples. Therefore, my code below could be a good compensation for learning. Of course, it's also a good reference for my own in the future.
Example Code for Preprocessor #/##, signal.h & atexit()
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=33&getYearMonth=20085
- Last Update: Wednesday, May. 7, 2008
- Peter Lee's Comments: I found a lot of text books cannot explain the C/C++ language so well due to lacking of vivid or understandable examples. Therefore, my code below could be a good compensation for learning. Of course, it's also a good reference for myself in the future.
My First VC-Implemented DLL Called in VB
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=32&getYearMonth=20084
- Last Update: Tuesday, Apr. 29, 2008
- Peter Lee's Comments: I have never used the DLL for data exchange among different languages. I'm familiar with C/C++, and I like to use C/C++ to implement a lot of algorithms. I also have some basic knowledge of Visual Basic, and I like to use VB for the user GUI development instead of VC++ (actually I don't know how to do at all). Therefore, I'm thinking of writing software with C/C++ for algorithm, and VB for GUI.
Transpose a Matrix (2-Dimesion Array) (转置一个矩阵(二维数组))
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=31&getYearMonth=20084
- Last Update: Friday, Feb. 13, 2009
- Peter Lee's Comments: It looks like a very simple problem for C/C++ learners. But as a matter of fact, I can make sure that a lot of programmers cannot solve it at their first try. Anyway, here is my C/C++ code written when I was reading the thick book The C++ Programming Language by Bjarne Stroustrup, the designer and implementor of the C++ Programming Language.
Microsoft Interview Question: 在一个单向链表里检查是否有一个“环”存在(Find a Loop in a Singly-Linked List)
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=24&getYearMonth=20084
- Last Update: Wednesday, Apr. 9, 2008
- Peter Lee's Comments: This is an interview question I ran into in Microsoft ATC (Shanghai) one year ago before my Master's graduation. The problem is actually quite simple even if you are not so familiar with the linked list, if only you are a little "smart".
Microsoft Interview Question: 反转一个单向链表(Reverse a Singly-Linked List)
Count in Your Head (Mental Arithmetic, 心算): Give the Weekday from a Gregorian(公历) Date
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=19&getYearMonth=20083
- Last Update: Thursday, Apr. 3, 2008
- Peter Lee's Comments: I've been thinking of the algorithm on how to compute the weekday from a Gregorian date. I remember, when I was still in high school, one of my classmates Yixiang Lv implemented an algorithm (only applies to 1900-3-1 ~ 2099-12-31) using Q-BASIC on his Pseudo-computer "Xiaobawang". He gave me the source code, but I couldn't find out how it works at that time. However, later I made it out, and implemented using Turboc C 2.0 when I was a freshman in Shanghai University. Furthermore, using this algorithm, you can compute the weekday from a Gregorian date (only applies to 1582-10-15 ~ 9999-12-31) in your head, if only you can memorize a digital string "033614625035".
Microsoft Interview Question: 把一个句子的所有单词按单词的反序输出(Output the Reversed-order of All the Words in a Sentence)
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=18&getYearMonth=20083
- Last Update: Wednesday, Nov. 26, 2008
- Peter Lee's Comments: This is an interview question I ran into in Microsoft GTSC (Shanghai) one year ago before my Master's graduation. The problem is actually very simple if you know how the built-in string operation function strtok works.
Game Point 24: All Non-repeated Verbose-brackets-free Solutions (24点游戏不重复的、没有冗余括号的所有解)
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=16&getYearMonth=20083
- Last Update: Monday, Mar. 31, 2008
- Peter Lee's Comments: Recently, I've been thinking of the algorithm on how to list all the non-repeated verbose-brackets-free solutions for the Game Point 24, which was a very popular maths card game when we were still children. I wrote a program for this algorithm, which tells me there totally 715 kinds of 4-number groups, 566 of which have one or more solutions, only 149 of which have no solution, based on the following assumptions and requirements. Click here to download all the solutions for 715 kinds 4-number groups (20080323_point24.txt, 395 KB) (Find for 3 3 8 8 [ascending order with a space between 2 numbers], you will get the sole solution: 8 / (3 - 8 / 3) = 24 ).
Sieve of Eratosthenes: List All Prime Numers (素数, 质数) Up To 100,000,000
- Homepage: http://www.peterlee.com.cn/blog.php?getArticleID=14&getYearMonth=20083
- Last Update: Wednesday, Jul. 7, 2010
- Peter Lee's Comments: In mathematics, the Sieve of Eratosthenes is a simple, ancient algorithm for finding all prime numbers up to a specified integer. It is the predecessor to the modern Sieve of Atkin, which is faster but more complex. It was created by Eratosthenes, an ancient Greek mathematician. Wheel factorization is often applied on the list of integers to be checked for primality, before the Sieve of Eratosthenes is used, to increase the speed.
C/C++ IDE: Visual C++ 2008 Express Edition
Processor: Intel(R) Core(TM)2 Duo CPU T7500 @ 2.20GHz 2.20GHz
Memory (RAM): 3070 MB
System Type: 32-bit Operation System, Windows Vista(TM) Home Basic
Totally 5761455 prime numbers found up to 100000000 using 4.940 seconds
Hi hackers, please don't attack my homepage. I'm just posting my thoughts and ideas about my work and life. Thank you so much!
Disclaimer: All information on this website is reserved by Peter Lee himself. Anyone who copies, distributes this information without Lee's permission is not allowed except for special demonstration ....