ref : http://stackoverflow.com/questions/2693776/removing-trailing-newline-character-from-fgets-input
- 11月 15 週四 201222:55
C_Cpp : 去除字串的'\n'
- 11月 11 週日 201215:20
C/C++ - pass parameter to callback function
ref : http://stackoverflow.com/questions/4644409/passing-parameters-for-callback-function
- 11月 02 週五 201217:51
C/Cpp : 在顯示的數字前面補0
在C中 , 我們可以用sprintf()來建立一個string的format ,
而有時我們會需要用到一些時間格式的format , 像2012-01-01 ,
這時就必須要數字1前面補0 ,
我們可以利用sprintf來達到我們想要的功能 :
而有時我們會需要用到一些時間格式的format , 像2012-01-01 ,
這時就必須要數字1前面補0 ,
我們可以利用sprintf來達到我們想要的功能 :
- 11月 01 週四 201216:23
C - popen()
在linux的C library中 , 提供了popen() function可以讓我們建立相同於pipeline的功能 ,
popen()的format如下:
FILE *popen(const char *command, const char *mode);
簡單的想 , popen會先執行command , 並傳回一個file pointer 指向該command output的內容,
popen()的format如下:
FILE *popen(const char *command, const char *mode);
簡單的想 , popen會先執行command , 並傳回一個file pointer 指向該command output的內容,
- 11月 01 週四 201211:48
C/Cpp : memset()
memset ( void * ptr, int value, size_t num ) , 可以讓我們對pointer所指向的一個記憶體空間塞入資料 ,
在memset中主要有三個參數 , 分別是:
ptr : Pointer to the block of memory to fill. value : Value to be set. The value is passed as an int, but the function fills the block of memory using the unsigned char conversion of this value. num : Number of bytes to be set to the value. for example :
在memset中主要有三個參數 , 分別是:
ptr : Pointer to the block of memory to fill. value : Value to be set. The value is passed as an int, but the function fills the block of memory using the unsigned char conversion of this value. num : Number of bytes to be set to the value. for example :
- 8月 02 週四 201222:37
C - static
在C中 , static是一個Storage-class specifiers,
它的主要作用有兩個,一個是作用域的限制,一個是指定存儲方式。
在作用域限制上:
以static申明的global variable、function不得被其他文件所引用.
它的主要作用有兩個,一個是作用域的限制,一個是指定存儲方式。
在作用域限制上:
以static申明的global variable、function不得被其他文件所引用.
- 8月 02 週四 201222:05
C - Volative
Compiler 在編譯程式時常常會對代碼進行優化的動作 ,
所謂優化的動作指的就是....舉個例子:
int i = 2;
int a = i;
所謂優化的動作指的就是....舉個例子:
int i = 2;
int a = i;
- 8月 02 週四 201220:35
c/c++ - sizeof()
在c中 , sizeof() function可以回傳該變數的位元組數目
for example:
int a;
sizeof(a); //sizeof(a) == 4 , 表示a這個變數為4個bytes.
for example:
int a;
sizeof(a); //sizeof(a) == 4 , 表示a這個變數為4個bytes.
- 4月 07 週六 201221:11
Cpp - When should I use a "private" constructor?
一般來說 , 宣告在private區域就是代表部給class以外的人使用 ,
所以若把constructor宣告在private區域 , 代表就是不可以對這個class instantize.
So...you should use private constructor when you don't want anyone outside the class to invoke that particular constructor.
The most common use that I see for private (and protected) constructors is in implementing singletons and some types of object factories.
所以若把constructor宣告在private區域 , 代表就是不可以對這個class instantize.
So...you should use private constructor when you don't want anyone outside the class to invoke that particular constructor.
The most common use that I see for private (and protected) constructors is in implementing singletons and some types of object factories.
- 4月 07 週六 201214:47
Cpp - iterator
