Time of Update: 2018-12-05
位元組長度,位元組對齊以及類,對象的長度struct st {short num;float math_grade;float Chinese_grade;float sum_grade;};int _tmain(int argc, _TCHAR* argv[]){cout << " sizeof('$')= " << sizeof ( ' $ ' ) << endl; cout << " sizeof(1)= " <<
Time of Update: 2018-12-05
C語言/C++中怎樣產生隨機數C語言/C++怎樣產生隨機數:這裡要用到的是rand()函數, srand()函數,C語言/C++裡沒有內建的random(int number)函數。(1) 如果你只要產生隨機數而不需要定義範圍的話,你只要用rand()就可以了:rand()會返回一隨機數值, 範圍在0至RAND_MAX 間。RAND_MAX定義在stdlib.h, 其值為2147483647。例如:#include<stdio.h>#include<stdlib.h>
Time of Update: 2018-12-05
目錄:1、??運算子使用2、GetEnumerator方法3、ResourceManager.GetString方法獲得Resources的字元。4、獲得Settings檔案的字元。一、??可能是一個被遺忘的運算子,很少看到有人用它,它的用法很簡單卻很實用:variable ?? defaultValue相當於variable == null ? defaultValue : variable有了它,一行便能搞定Lazy Evaluation了:使用??之前:Code highlighting
Time of Update: 2018-12-05
1、#include<iostream.h>#include <time.h>#include <sys/types.h>#include <sys/stat.h>#include <stdio.h>void main( void ){struct stat buf;int result;//獲得c:\Windows\Calc.exe檔案的資訊result =stat( "c:\\windows\\Calc.exe",
Time of Update: 2018-12-05
地址:http://blog.163.com/mad010@126/blog/static/12237155200841645952814/[文章導讀]C#中不僅支援.Net 平台,而且支援COM平台。為了支援 COM和.Net,C# 包含一種稱為屬性的獨特語言特性第六節、介面轉換 C#中不僅支援.Net 平台,而且支援COM平台。為了支援 COM和.Net,C# 包含一種稱為屬性的獨特語言特性。一個屬性實際上就是一個 C# 類,它通過修飾原始碼來提供元資訊。屬性使 C# 能夠支援特定的技術,
Time of Update: 2018-12-05
一、擷取當前檔案的路徑1. System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName 擷取模組的完整路徑,包括檔案名稱。2. System.Environment.CurrentDirectory 擷取和設定目前的目錄(該進程從中啟動的目錄)的完全限定目錄。3. System.IO.Directory.GetCurrentDirectory()
Time of Update: 2018-12-05
c++中指標,指標的引用,指標的指標的區別看例子和結果:#include "stdafx.h"#include <iostream>using namespace std;void FreePtr1(int* ptr1){ delete ptr1; ptr1 = NULL;}void FreePtr2(int*& ptr2){ delete ptr2; ptr2 = NULL;} void FreePtr3(int **ptr3){ dele
Time of Update: 2018-12-05
1、stable_partition穩定劃分和partition不穩定劃分。 #include <iostream>#include <algorithm>#include <vector>using namespace std;struct Student {char name[20];int age;};ostream & operator <<(ostream & os, const Student &s){os
Time of Update: 2018-12-05
為了避免同一個檔案被include多次,可以使用以下兩種方式1 #ifndef方式 2 #pragma once方式 方式一: #ifndef __SOMEFILE_H__ #define __SOMEFILE_H__ ... ... // 一些聲明語句 #endif 方式二: #pragma once ... ... // 一些聲明語句 包含pragma once語句的檔案只會被編譯一次。
Time of Update: 2018-12-05
一、extern "c "的作用:用來告訴編譯器,該函數是用C語言編寫的. 二、以下幾種使用方式:1.extern "c " void exit(int)//包含c語言中編寫的exit函數. 2.extern "c " { int printf(const char* ....); int scanf(char *...) ; ....}//包含c語言中編寫的一組函數. 3.extern "c "{#include
Time of Update: 2018-12-05
基於 Visual C++6.0 的 DLL 編程實現 一、前言 自從微軟推出 16 位的 Windows 作業系統起,此後每種版本的 Windows 作業系統都非常依賴於動態連結程式庫 (DLL) 中的函數和資料,實際上 Windows 作業系統中幾乎所有的內容都由 DLL 以一種或另外一種形式代表著,例如顯示的字型和表徵圖儲存在 GDI DLL 中、顯示 Windows 案頭和處理使用者的輸入所需要的代碼被儲存在一個 User DLL 中、 Windows 編程所需要的大量的 API
Time of Update: 2018-12-05
非託管的vc工程中部分檔案使用.Net Framwork原文地址 使用vs2005環 境 ,且工程不使用與編譯標頭檔stdafx.h.(保證可以,不可以來找我!) 一,建立一般的c++的console32的project ,name: Test ,工程setting使用預設,不改變.如下: 原文地址二,add header file: ManagedCppClass.h#pragma onceclass ManagedCppClass{public: void PrintString()
Time of Update: 2018-12-05
用法一、Checked與Unchecked
Time of Update: 2018-12-05
C++高效編程忠告這是對C++高效編程的一個總結, 很有指導作用.一、#include “filename.h”和#include <filename.h>的區別 #include “filename.h”是指編譯器將從當前工作目錄上開始尋找此檔案 #include <filename.h>是指編譯器將從標準庫目錄中開始尋找此檔案二、標頭檔的作用 加強安全檢測 通過標頭檔可能方便地調用庫功能,而不必關心其實現方式三、* , &修飾符的位置 int *i,j; /
Time of Update: 2018-12-05
在編程時,也許你會看到函式宣告或定義中會出現CALLBACK和WINAPI兩個宏。其實,它們也是__stdcall的代名詞。看windef.h中的內容:#define CALLBACK __stdcall#define WINAPI __stdcall__stdcall是調用類型.調用類型有:__fastcall、__cdecl、__stdcall。 1、__cdecl調用類型:
Time of Update: 2018-12-05
記憶體配置方式有三種:(1) 從靜態儲存地區分配。記憶體在程式編譯的時候就已經分配好,這塊記憶體在程式的整個運行期間都存在。例如全域變數,static 變數。(2) 在棧上建立。在執行函數時,函數內局部變數的儲存單元都可以在棧上建立,函數執行結束時這些儲存單元自動被釋放。棧記憶體配置運算內建於處理器的指令集中,效率很高,但是分配的記憶體容量有限。(3) 從堆上分配,亦稱動態記憶體分配。程式在啟動並執行時候用malloc 或new 申請任意多少的記憶體,程式員自己負責在何時用free
Time of Update: 2018-12-05
C#中同時存在String與stringMSDN中對string的說明: string is an alias for String in the .NET Framework。string是String的別名而已,string是c#中的類,String是Framework的類,C# string 映射為 Framework的 String。如果用string,編譯器會把它編譯成String,所以如果直接用String就可以讓編譯器少做一點點工作。
Time of Update: 2018-12-05
AFX_MANAGE_STATE(AfxGetStaticModuleState())的作用:用於模組切換時的狀態保護,1.AfxGetStaticModuleState()指向當前模組狀態;2.當前函數調用結束後原模組的狀態自動被恢複;3.用於DLL中所調用MFC函數、類、資源時的模組狀態切換;[MSDN]By default, MFC uses the resource handle of the main application to load the resource template.
Time of Update: 2018-12-05
1、首先在項目屬性—>產生->“允許不安全的程式碼”勾選2、使用方式 第一種:函數前加unsafe 第二種:在代碼的外面加unsafe{}; 如: unsafe static void TestPtrInCS() { { int* array = stackalloc int[10]; for (int i = 0; i < 10; i++)
Time of Update: 2018-12-05
[轉]http://blog.csdn.net/maotin/archive/2008/09/25/2977138.aspxC#3.0新體驗(三)maotin20080925 前言: