Time of Update: 2018-12-03
1、什麼是static? static 是C++中很常用的修飾符,它被用來控制變數的儲存方式和可見度。 2、為什麼要引入static? 函數內部定義的變數,在程式執行到它的定義處時,編譯器為它在棧上分配空間,大家知道,函數在棧上分配的空間在此函數執行結束時會釋放掉,這樣就產生了一個問題: 如果想將函數中此變數的值儲存至下一次調用時,如何??
Time of Update: 2018-12-03
轉載地址http://blog.renren.com/share/425935703/14545505748?from=0101010202&ref=hotnewsfeed&sfet=102&fin=48&fid=20050008831&ff_id=425935703char *p, **p, ***p;char p[],p[][],p[][][];char *p[],*p[][],**p[],**p[][],*(*p)[],(**p)[],(**p)[]
Time of Update: 2018-12-03
1.有關整數溢出,直接上代碼#include<stdio.h>int main(void){int i = 2147483647;unsigned int j = 4294967295;printf("%d*%d**%d\n",i,i+1,i+2);printf("%u*%u**%u\n",i,i+1,i+2);printf("%d*%d**%d\n",j,j+1,j+2);printf("%u*%u**%u\n",j,j+1,j+2);getchar();return
Time of Update: 2018-12-03
作為一個經驗豐富的C/C++程式員, 肯定親手寫過各種功能的代碼, 比如封裝過資料庫訪問的類, 封裝過網路通訊的類,封裝過日誌操作的類, 封裝過檔案訪問的類, 封裝過UI介面庫等, 也在實際的項目中應用過, 但是回過頭仔細想想,其實以前自己寫過的這些代碼,只能是在特定的項目或者特定的環境中使用, 對於自己來說, 在不同的項目中應用, 只需要複製代碼, 改改也就可以了, 因為自己寫的代碼自己很熟悉。問題是, 你封裝的這些庫, 在給別人使用的時候, 別人用起來是否很方便,
Time of Update: 2018-12-03
這學期的課程設計是嵌入式-手機24點遊戲開發! 今天,搭建了arm開發板上的wince開發環境,用的是EVC來進行程式的開發!雖說一樣都是C++,文法上沒有多大的變化(自己感覺)!但是有些處理細節上還是需要多注意的! 這次遇到了兩個主要的問題:
Time of Update: 2018-12-03
C++中當 vector 中的資料類型為基本類型時我們調用std::sort函數很容易實現 vector中資料成員的升序和降序排序,然而當vector中的資料類型為自訂結構體類型時,我們該怎樣實現升序與降序排列呢?有兩種方法,下面的例子能很好的說明: 方法1: 我們直接來看代碼吧,比較簡單,容易理解: #include "stdafx.h" #include <vector> #include
Time of Update: 2018-12-03
原文在 http://blog.sina.com.cn/s/blog_6e273ebb0100pid0.html 長期一來,Hadoop因為其Java實現帶來的效能問題而飽受爭議,同時也湧現了很多方案來緩解這一問題。Jeff Hammerbacher(Cloudera首席科學家)曾在Quora上寫過這樣一段:-----------------------------------------------------------------------------------------------
Time of Update: 2018-12-03
c:static unsigned char LRC(auchMsg,usDataLen) unsigned char *auchMsg ; /* 要進行計算的訊息 */ unsigned short usDataLen ; /* LRC 要處理的位元組的數量*/ { unsigned char uchLRC = 0 ; /* LRC 位元組初始化 */ while (usDataLen--) /* 傳送訊息 */ uchLRC += *auchMsg++ ;
Time of Update: 2018-12-03
FFMpeg中apiexample.c例子分析——解碼分析收藏 我們直接從video_decode_example()函數開始講,該函數實現了如何去解碼一個視頻檔案,以.mpeg文件為例。 (1)將緩衝的末尾清0,從而確保讀操作不會越界導致破壞mpeg流。 uint8_tinbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; memset(inbuf +INBUF_SIZE, 0,
Time of Update: 2018-12-03
管道一般用與父子進程之間通訊,下面是一個簡單的父子進程通訊案例: #include <unistd.h>#include <stdio.h>int main(){int fd[2];//管道入口fd[0]為讀,fd[1]為寫入口char r_buf[100];char w_buf[20]= "hello word!";pid_t pid;if(pipe(fd) < 0)//建立管道{printf("pipe error!\n");exit(1);}if((pid
Time of Update: 2018-12-03
// 演算法.cpp : 定義控制台應用程式的進入點。//#include "stdafx.h"#include <iostream>#include <ctime>using namespace std;void QuickSort(int e[], int first, int end);int _tmain(int argc, _TCHAR* argv[]){srand(unsigned(time(NULL)));//set 種子int t_nArray[10];/
Time of Update: 2018-12-03
一段關於定時器的程式 // ThunderFind.cpp : 定義控制台應用程式的進入點。//#include "stdafx.h"#include <iostream>#include <stdio.h> #include "map.h"#include <windows.h>using namespace std;map m;//m為map類的對象聲明為全域的才能使用定時器void CALLBACK addThunderTenMin(HWND
Time of Update: 2018-12-03
c++中string可以通過string.length()來獲得string的長度,當對與一個數組來說就不是這麼容易了。如一個int型的數組:int a[] = {1,2,3,5,6,9};如何獲得呢?可以通過sizeof的特殊用法,都知道sizeof()是獲得所佔的空間的大小,所以可以:int length = sizeof(a)/sizeof(int);來得到a數組的元素個數。1.vector
Time of Update: 2018-12-03
1-1 : 正確1-2 : 不正確 std::string exclam = "!";std::string message = "hello" + ", world" +exclam;錯!( error C2110: cannot add twopointers)std::string message = exclam +"hello" + ", world" ; 正確!std::string message = "hello" +exclam + ", world" ;正確! 1、2題解釋:
Time of Update: 2018-12-03
在C語言中偶爾會遇到如下面的語句:#define paster( n ) printf( "token" #n " = %d", token##n )首先說調用paster(9)的結果為token9=9(假設定義了 int token9=9)。##串連符號由兩個井號組成,其功能是在帶參數的宏定義中將兩個子串(token)聯結起來,從而形成一個新的子串。但它不可以是第一個或者最後一個子串。所謂的子串
Time of Update: 2018-12-03
前幾天參加C#培訓,發現其中的FORMAT參數替換功能實在是實用,尤其是在寫SQL語句的時候,比如一個SQL 陳述式insert into (f1,f2,f3) values (v1,v2,v3)如果要用VB來寫,要加一串的 "" 和 & 連字號,實在是難寫又難看。基本上只要參數一多,幾乎100%要寫錯。如果用C#來寫,就是這樣str sql="insert into (f1,f2,f3) values ('{0}','{1}','{2}')"sql=sql.string.format(
Time of Update: 2018-12-03
索引靜態化並不是單例 (Singleton) 模式餓漢模式懶漢模式 (堆棧-粗糙版)懶漢模式 (局部靜態變數-最佳版)範例代碼和注意事項 (最優實現)擴充閱讀參考資料我非常贊成合理的使用 設計模式 能讓代碼更容易理解和維護, 不過我自己除了簡單的 單例 (Singleton) 模式 外, 其它都很少用 可恥的是, 直到前段時間拜讀了 C++ In Theory: The Singleton Pattern, Part I, 我才發現自己的 單例 (Singleton)
Time of Update: 2018-12-03
剛剛看過這篇《30 years of C》,回想了這幾年的學習曆程。 在大學裡,我學習的第一門程式設計語言是C,但花時間最多的還是C++。大約五年前,開始啃《
Time of Update: 2018-12-03
方法聲明(dstring.h):/**************************************************************************** * Dynamic strings ****************************************************************************//* * tcl.h -- * * This header file describes the
Time of Update: 2018-12-03
C語言與Java的異同 作者:終南 <li.zhongnan@hotmail.com>