Time of Update: 2018-12-07
Fedora13安裝VMwareTools 出現 : What is the location of the directory of C header files that match your runningkernel?The path "" is not valid.Would you like to change it? [yes]解決辦法:1.將VMwareTools-
Time of Update: 2018-12-07
在(原創) 如何動態建立二維陣列(多維陣列)? (高級) (C)中,我們看到用C語言動態建立二維陣列並不是件容易的事情,但在C++有沒有更好的解法呢?在(原創) 如何動態建立一維陣列? (初級) (C/C++)
Time of Update: 2018-12-07
由於C++相容於C,為了用C++維護以前用C寫的程式,可能會遇到用C寫的array,但C++的std::vector遠比array好用,所以可能必須將array轉成std::vector繼續維護,以下的程式demo如何將array轉成std::vector。 1/**//* 2(C) OOMusou 2006 http://oomusou.cnblogs.com 3 4Filename : ArrayToVectorByConstructor.cpp 5Compiler : Vis
Time of Update: 2018-12-07
Abstract由於C++/CLI的加入,現在Visual C++ 9最少就有三種字串:C-Style string、STL string與.NET string,要怎麼在這三種字串互轉呢?Introduction使用環境:Visual C++ 9.0 / Visual Studio
Time of Update: 2018-12-07
Abstract一個很簡單的題目,來看看C和C++要如何實現。IntroductionC語言1 /* 2 (C) OOMusou 2008 http://oomusou.cnblogs.com3 4 Filename : array_minus_1.c5 Compiler : Visual C++ 8.06 Description : Demo how to minus 1 in each element of array7 Release : 03/26/2008 1.08
Time of Update: 2018-12-07
原文地址:http://www.cnblogs.com/dolphin0520/archive/2011/10/03/2198493.html當多個資料需要共用記憶體或者多個資料每次只取其一時,可以利用聯合體(union)。在C Programming Language 一書中對於聯合體是這麼描述的: 1)聯合體是一個結構; 2)它的所有成員相對於基地址的位移量都為0;
Time of Update: 2018-12-07
http://www.cppreference.com/operator_precedence.html PrecedenceOperatorDescriptionExampleAssociativity1()[]->.::++--Grouping operatorArray accessMember access from a pointerMember access from an objectScoping
Time of Update: 2018-12-07
原文地址:http://blog.csdn.net/xcyuzhen/article/details/4543264C++中棧區 堆區 常量區(由一道面試題目而學習)2009-04-28 21:01 #include<iostream.h>void main(){char a[]="abc";棧 char b[]="abc";棧 char* c="abc";abc在常量區,c在棧上。char* d="abc"; 編譯器可能會將它與c所指向的"abc"最佳化成一個地方。const
Time of Update: 2018-12-07
使用vector.insert將array轉vector,雖然也是一行完成,但不是那麼直觀,建議還是用constructor的方式將array轉std::vector。 1/**//* 2(C) OOMusou 2006 http://oomusou.cnblogs.com 3 4Filename : ArrayToVectorByInsert.cpp 5Compiler : Visual C++ 8.0 6Description : Demo how to convert arr
Time of Update: 2018-12-07
Abstractfor_each()是STL中少數可以回傳值的algorithm,此範例在展示for_each()此特殊功能與function object可以留住state的特性。Introductionfunction object與global function的差別除了function object可以傳入參數外,還可以不使用static就可以留住state。一個簡單的需求,想要每印n個數字就換行,並且統計出所有iterator的和,所以function
Time of Update: 2018-12-07
很懷念VB和C#的foreach文法嗎?對於C++只能用for文法造成程式冗長覺得很煩嗎?foreach的確對於container而言非常好用且精簡,C++/CLI已經增加上了for each文法了,事實上,C++也可使用foreach喔,STL提供了for_each() algorithm,可以彌補這個缺憾。for_each() algorithm會將每個iterator當作const iterator處理,若只用普通的function,直接將function
Time of Update: 2018-12-07
Abstract在(原創) 如何將字串前後的空白去除? (使用string.find_first_not_of, string.find_last_not_of) (C/C++) (STL) 中已經可順利將字串前後的空白去除,且程式相當的精簡,在此用另外一種方式達到此要求,且可同時將whitespace去除,並且使用template寫法。Introduction原來版本的程式在VC8可執行,但無法在Dev-C++執行,目前已經修正。stringTrim1.cpp / C++1 /* 2 (C)
Time of Update: 2018-12-07
Abstract若要使function傳回一個值,可以使用return,若要傳回兩個以上的值呢?Introduction要使function傳回兩個以上的值,方法還不少,最簡單的方式是使用pass by address / pass by
Time of Update: 2018-12-07
Abstract要判斷奇數偶數,我們都會想用%,最近在Verilog發現一個小技巧也可用在C/C++...Introduction在(原創) 如何設計除頻器? (SOC) (Verilog) (MegaCore)中有一小段code如下:assign o_clk = (N == 1) ? clk : (N[0]) ? (clk_p | clk_n) :
Time of Update: 2018-12-07
Abstract若需要將程式碼放進word交報告或做檔案時,或許我們會想將程式碼加上行號方便講解,如同部落格園顯示程式碼那樣,我們該如何做呢?Introduction使用環境:Visual C++ 9.0 / Visual Studio 2008一段C++的小程式,可以幫程式碼加上行號後輸出。map_code_line.cpp / C++1 /* 2 (C) OOMusou 2008 http://oomusou.cnblogs.com3 4 Filename :
Time of Update: 2018-12-07
Abstract這是一個初學者常犯的錯,不過卻是一個很好的問題,充分表現出指標的特色。Introduction一個很簡單的C語言,只有6行。C語言1 #include <stdio.h>2 3 int main() {4 int *ptr = 345;5 printf("%d\n", *ptr);6 }在不同的compiler會有不同結果,在VC6不能編譯,會有錯誤訊息,在VC8則無錯誤訊息,但run-time會錯。4行int *ptr =
Time of Update: 2018-12-07
Abstract二維陣列和字串陣列是個很類似的東西,The C Programming Language還特別提出一小節來探討,我們來看看兩者的差異在哪裡?Introduction在The C Programming Language 2nd 5.9節 p.113標題為Pointers vs. Multi-dimensional Arrays,特別討論二維陣列與字串陣列的差別,不過他並沒有提出實際的範例來解釋,我試著用了一個簡單的範例來探討。C語言1 /* 2 (C) OOMusou 2008
Time of Update: 2018-12-07
AbstractC語言並沒有提供一個函數專門將int, double轉字串,必須透過一個小技巧。Introduction有的compiler有提供itoa()與ltoa()將int, double轉字串,不過這些並非ANSI C標準,真正標準該使用sprintf()。double_to_string.c / CCode highlighting produced by Actipro CodeHighlighter
Time of Update: 2018-12-07
Abstractprintf()只能顯示10、8、16進位的值,卻無法顯示2進位的值,但有時候我們會希望能直接顯示2進位數字。Introduction使用環境:Visual C++ 8.0 / Visual Studio 2005Method 1:這是從C Primer Plus 5/e改寫的,使用bit運算來將10進位轉2進位,相當漂亮的寫法。decimal2binary.c / CCode highlighting produced by Actipro CodeHighlighter
Time of Update: 2018-12-07
AbstractOpenCV是一個C/C++開源的Computer Vision(計算機視覺)函式庫,在Windows上只要直接安裝即可,但在Linux需手動編譯,本文為我在CentOS 5.1的編譯心得。IntroductionStep 1:至SourceForge.net : Open Computer Vision Library下載Linux版的opencv-1.0.0.tar.gz。Step 2:將opencv-1.0.0.tar.gz解壓縮[root@localhost ~]#