原创 1.2 boost庫學習--類型轉換(數值類型to字符串)

#include <boost/lexical_cast.hpp> using boost::lexical_cast; #include <iostream> using namespace std; int main() { /

原创 1.4 boost::array用法

boost::array 與 std::vector幾乎完全一樣,只不過boost::array是限定大小的。 具體用法,見下面例程: #include <boost/array.hpp> using boost::array; #in

原创 獲取本機時間的四種方式

  //方案— 優點:僅使用C標準庫;缺點:只能精確到秒級 #include <time.h> #include <stdio.h> int main( void ) {     time_t t = time(0);    

原创 1.1 boost庫學習--類型轉換(字符串to數值類型)

  #include <boost/lexical_cast.hpp> using boost::lexical_cast; #include <i

原创 1.3 boost::any 用法

代碼如下: #include <boost/any.hpp> using boost::any; #include <iostream> #include <list> #include <string> using namespace

原创 統計unsigned int 二進制1的個數!

unsigned int GetBinaryCount(unsigned int u) { u = ((u&0x55555555) + ((u>>1)&0x55555555)); u = ((u&0x33333333

原创 判斷基於對話的程序是開機啓動還是雙擊運行的

我們這裏的開機啓動是寫到註冊表裏面, 我們可以在啓動的時候加參數,比如: test.exe -a 1 -b 2 然後呢, 在test app中 用 利用GetCommandLineW()函數獲得命令行參數個數, 用CommandLine

原创 ubuntu 後臺運行的幾種方法!

第一種:使用 “nohup”,即 "nohup ./test.sh &",忽略hangup信號,防止終端關閉時程序退出。 運行狀態可以用 “jobs -l” 來查看。   第二種:使用 “setsid” 即 “setsid ./test.

原创 C++拷貝構造函數的幾個細節

一 拷貝構造函數是C++最基礎的概念之一,大家自認爲對拷貝構造函數了解麼?請大家先回答一下三個問題: 1. 以下函數哪個是拷貝構造函數,爲什麼? X::X(const X&);    X::X(X);    X::X(X&, int 

原创 僅通過崩潰地址找出源代碼的出錯行

      作爲程序員,我們平時最擔心見到的事情是什麼?是內存泄漏?是界面不好看?……錯啦!我相信我的看法是不會有人反對的——那就是,程序發生了崩潰! “該程序執行了非法操作,即將關閉。請與你的軟件供應商聯繫。”,呵呵,這句 M$ 的“

原创 sscanf巧用格式字符串。

名稱: sscanf()  從一個字符串中,讀入指定格式的數據。 函數定義:  int sscanf( const char *buffer, const char *format [, argument ] ... ); 參數: buf

原创 c 不定參數的函數

#include <stdio.h> #include <string.h> #include <stdarg.h> void arg_int( int count, ... ); void arg_str( int count, .

原创 判斷當前網絡是否連通?

      有時候,我們需要判斷是否可以上網,比如說QQ,當網線撥出來的時候它,怎麼能知道現在掉線了呢?我猜它肯定會啓動啓動一個線程隔段時間檢查下網絡情況吧(具體是不是這樣,我也不知道),如果真的有這麼一個要求,我們怎麼實現呢。下面我就提

原创 填充背景的三種方法

IDB_BG 是位圖資源的ID 方法一 OnEraseBkgnd(CDC* pDC) {     // 設置畫刷爲希望的背景     CDC backBmp;     backBmp.CreateCompatibleDC(pDC);   

原创 如何 給 iOS UIFont 設置字重?

如何 給 iOS UIFont 設置字重 UILabel *label = [[UILabel alloc] init]; if (@available(iOS 8.2, *)) { label.font = [UIFont sy