原创 內存結構-堆結構-內存分配函數

內存管理(從底層到高層): 硬件層次 內存結構管理 內核層次 內存映射 堆擴展 語言層次  c::malloc     c++:new 數據結構 STL(Standard Template Library,標準模板庫)

原创 error C2079: “out”使用未定義的 class“std::basic_ofstream”

問題: error C2079: “out”使用未定義的 class“std::basic_ofstream<_Elem,_Traits>” 解決: #include<fstream>

原创 學習體系

語言: c c++ 算法: 算法 數據結構 基礎(系統 核心(Kernel)編程): ------------------------------系統 Linux/Unix Window MacOSX ------------------

原创 實現qsort函數原型

快速排序,作爲能唯一能存在於庫函數裏的排序算法,qsort()的優勢就在於非常靈活. 用man qsort 查看其文檔 void qsort(void *base,int nelem,int width,int (*fcmp)(cons

原创 VS2010遇到了異常,可能是由某個擴展導致的

from:http://blog.csdn.net/yilip/article/details/7657015   今天打開好久沒用的Microsoft Visual Studio 2010 ,剛纔創建了一個C++工程,錯誤就出現

原创 void main() 還是int main()

void main()還是int main()     最近在論壇上看到有不少網友的程序中,main函數都寫成void main(),而不是int main()。那麼,到底哪個是正確的,或至少是推薦使用的呢?這篇文章本來是自己想寫的,但

原创 scanf("%d\n",&a)和scanf("%d",&a) 前者爲什麼我輸入一個數字後一直按回車都無法結束 除非輸入數字回車

在scanf中\n不表示接受一個回車符,而是表示忽略所有的空白字符,包括回車,空格,tab 所以想要結束輸入,輸入任意一個非空白字符即可,但是該字符仍然會留在緩衝區中,所以一般不建議在 scanf中使用\n

原创 二叉樹

#include <iostream> using namespace std; #include <iomanip> typedef char T; class bst{ struct Node{ T data; Node*

原创 c語言中兩個scanf爲什麼會出毛病?

那是因爲在我們做了第一次輸入時,並按下回車,使程序繼續執行。而那個回車也隨之進入了流當中。而遇到第二個scanf()時,scanf()把回車當作是第二次輸入的字符而接收。因此程序也就忽略了輸入而繼續執行了。這個回車就是在做輸入時產生的垃圾

原创 快速排序

#include <algorithm> using std::swap; void sort(int* a, int n) { if(n<=1) return; if(n==2){ if(a[1]<a[0]) swap(a[1]

原创 perror() 和 dlerror()

今天同學問了個問題, 爲什麼包含了<dlfcn.h> 用dlopen 還提醒未定義 我拿源碼來看了下 #include <stdlib.h> #include <dlfcn.h> #include "add.h" #include <s

原创 linux c下如何實現不需要回車讀入一字符

/*getch()可以做到,但getch()需要用到ncurse庫*/ #include <stdio.h> #include <stdlib.h> int main(void) { int c;

原创 選擇排序

#include <algorithm> using std::swap; void sort(int* a, int n) { //反覆n-1次 for(int i=0; i<n-1; i++){ // 第i次從第i~n個數據中找

原创 ClistCtrl 的ICON模式下,不顯示圖標

Q:在一個對話框里加入了CListCtrl 控件,模式是ICON的,可是用下面的代碼初始化不顯示圖標,是怎麼回事, A: 這可是MFC的經典錯誤啊,使用CImageList的局部變量,改正最簡單的辦法加上static修飾 或者改爲成員變

原创 二分查找法

#include <iostream> using namespace std; class Person{ string name; int age; string addr; public: Person(const char