Time of Update: 2018-12-05
C代碼如下:#include "stdio.h"__declspec(dllexport) int Call(int (*qq)(int num),char * str){ printf(str); return
Time of Update: 2018-12-05
參考網址:1.http://blog.csdn.net/miyunhong/archive/2010/09/24/5903857.aspx2.http://developer.51cto.com/art/201001/180130.htm3.http://developer.51cto.com/art/201002/182348.htm4.http://tech.sina.com.cn/s/2004-09-17/0735426801.shtml5.http://blog.chinaunix.ne
Time of Update: 2018-12-05
// 指標.cpp : 定義控制台應用程式的進入點。//#include "stdio.h"void change(int **p1,int **p2){ int *tem; tem=*p1; *p1=*p2; *p2=tem;}void changeNormal(int *p1,int *p2){ int temp=*p1; *p1=*p2; *p2=temp;}void changeErr(int *p1,int *p2){ int *
Time of Update: 2018-12-05
#include "stdio.h"#include "malloc.h"#include <sys/stat.h>//擷取檔案大小long GetSize(char* path){ //第一種方法擷取檔案大小 long currentPosition; long size; FILE *fp; fp=fopen(path,"rb"); /* Save the current position. */
Time of Update: 2018-12-05
資料訪問是任何應用程式的基礎。在本文中,我將說明如何用C#和ADO.NET訪問基於SQL Server的資料,以及如何在一個資料繫結的網格控制項中顯示資料。我用一個簡單的C#應用程式為例。ADO.NET結構 使用ADO.NET不需要維持一個串連。另外,在ADO.NET中,只需用幾行代碼,你就可以從一個資料來源轉到另一個資料來源。 ADO.NET的核心對象有Command, Connection, DataReader和DataAdapter。它們是.NET中所有資料操作的基礎。
Time of Update: 2018-12-05
轉自:http://hi.baidu.com/oohacker/blog/item/6004e6fb712feb254e4aea24.html 有關C#鎖語句的討論網上說得很多, 但絕大多數只說了了怎麼用, 對於lock的注意事項卻很少, 尤其是關於lock(this), lock(typeof(ClassName))以及lock("thisLock")的討論更是鳳毛麟角,
Time of Update: 2018-12-05
C/C++:#include "stdio.h"struct People{ int age; int arr[3];};void main(){ //printf("%d\n",sizeof(People)); struct People m={3,{4,5,6}}; struct People m2=m; m2.arr[2]=99; printf("%d\n",m.arr[2]);}C#:using System;using
Time of Update: 2018-12-05
//產生隨機任意字母長度組合 public string RndNum1(int VcodeNum) { string Vchar = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; string VNum = ""; Random rand = new Random(); for (int i = 0; i < VcodeNum; i++) {
Time of Update: 2018-12-05
#include<stdio.h>struct stu{ char name[10]; int num; int age; char addr[15];}boya[2],boyb[2],*pp,*qq;void main(){ FILE *fp; char ch; int i; pp=boya; qq=boyb; if((fp=fopen("d:\\stu_list","wb+"))==NULL) {
Time of Update: 2018-12-05
#include <stdarg.h>#include <stdio.h>int sum(int num, int arg, ...); void main(){ int num=sum(5,1,2,3,4,5); printf("%d\n",num);}int sum(int num, int arg, ...){ int n,summary; va_list ap; if(num < 1) return 0
Time of Update: 2018-12-05
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.IO;namespace Test{ delegate void MyDelegate(); delegate MyClosure Closure(); class Program { static void Main(string[] args) {
Time of Update: 2018-12-05
編寫C程式如下:#include "stdio.h"__declspec(dllexport) void MyFun(){ printf("this is a dll\n");} 儲存,取名為My.C 運行 VS 命令提示,Cl /c 路徑/My.c運行以後會產生 My.Obj,預設在vs安裝資料夾的VC目錄下再運行 link/dll 路徑/My.obj在同一個目錄會產生My.dll 在C#中調用:將dll複製到bin目錄,編寫如下C#代碼:static void
Time of Update: 2018-12-05
int num = 1000000; B b = new B(); B[] arr=new B[num]; B[] mmm = new B[num]; for (int i = 0; i < num; i++) { arr[i] = new B(); //下面兩句代碼只能選一句,運行,在工作管理員中查看程式的記憶體佔用量
Time of Update: 2018-12-05
// strtref.cpp -- using structure references#include <iostream>using namespace std;void Fun(const int *num){ //num=435; cout<< *num<<",const fun"<<endl;}void Fun(int *num){ //num=435; cout<<
Time of Update: 2018-12-05
先看一段C的代碼(注意,如果在vs中編譯此代碼,需要將尾碼名設定為.c而不是.cpp,因為尾碼名為c的話vs才會使用C的編譯器)#include<stdio.h> int main(int argc, const char * argv[]) { //在C語言中const修飾的是一個唯讀變數,並不是一個常量 const int num=99; //這一句會編譯報錯。因為ANSI C規定數組定義時維度必須是常量,唯讀變數也是不可以的 //int arr[num
Time of Update: 2018-12-05
// 指標.cpp : 定義控制台應用程式的進入點。//#include "stdio.h"void main(){ int a[3][3]={{1,2,3},{4,5,6},{7,8,9}}; //a[i],*(a+i)和a+i,&a[i] printf("*a[i]為:%d\n",*a[0]); printf("**(a+i)為:%d\n",**(a+0)); printf("**a為:%d\n",**a);
Time of Update: 2018-12-05
main.cpp源碼如下:#include<iostream>/*如果沒用extern "C"包含#include "My.h",編譯器會報錯*//*如果不用extern "C"包含#include "My.h",將My.c的尾碼名改為cpp(My.cpp)也能編譯成功*/ //extern "C"//{ #include "My.h"//}void main(){ Print();}My.h源碼如下://如果在此處聲明為extern "C" void
Time of Update: 2018-12-05
// 分配記憶體空間.cpp : 定義控制台應用程式的進入點。//#include "stdio.h"#include "malloc.h"struct Student{ int id; char *name; int score; struct Student *next;};void errorFun(){ struct Student stu={1,"wq",99}; struct Student *head,*s1; for(int i=0;i&
Time of Update: 2018-12-05
1.string Fun1(){ string num="ly"; return num;} //在程式中使用此方法不會報錯,因為方法執行完畢以後雖然num被釋放,但是num的值會被儲存到一個臨時儲存單元,然後從臨時儲存單元複製到調用此方法給其賦值的變數中去(如:在main方法中:string mynum=Fun1(),num的值就會被儲存到mynum)2.string& Fun2() { string num="ly"; return num; }
Time of Update: 2018-12-05
http://blog.chinaunix.net/u1/37000/showart_338364.html // C語言讀寫檔案.cpp : 定義控制台應用程式的進入點。//#include "stdio.h"#include "string.h"void write(){ FILE *fp; //唯寫開啟或建立一個文字檔,只允許寫資料 fp=fopen("D:\\c.txt","wt"); if(fp!=NULL) { char