上一页 1 ··· 7 8 9 10 11 12 13 14 下一页
摘要: C#:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 结构{ class Program { static void Main(string[] args) { A a; a.age = 111; a.arr = new int[] { 11, 22, 33 }; A a2 = a; a2.age = 99; a2.arr[0] = 66; B b = new B(); b.age = 111; b.arr = new int[] { 11, 22, 33 } 阅读全文
posted @ 2010-09-26 19:55 再快一点 阅读(3042) 评论(0) 推荐(0) 编辑
摘要: public class MyCache{ /// summary /// 插入一个缓存 /// /summary /// param name="name"缓存键/param /// param name="value"缓存值/param /// param name="isAbsoulute"是否使用绝对过期,是则为true否则为false/param /// param name="isOverride"如果缓存存在,是否覆盖缓存值/param /// param name="absoluteDate"绝对过期时间/param /// p 阅读全文
posted @ 2010-09-26 18:50 再快一点 阅读(774) 评论(0) 推荐(0) 编辑
摘要: 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 System.Collections.Generic;using System.Linq;using System.Text;namespace 结构{ class 阅读全文
posted @ 2010-09-26 00:09 再快一点 阅读(190) 评论(0) 推荐(0) 编辑
摘要: #include "stdio.h"struct People{ int age; int arr[3];//这里如果不指定数组大小,在turboc中编译不能通过,但在vs2008中可以};void main(){ struct People m={3,{4,5,6}}; struct People p,p2; p.age=9; p2=p; p2.age=456; printf("%d\n",p.age); printf("%d\n",m.arr[2]); //在vs2008中,如果上面的结构定义时不指定数组元素的大小,则sizeof(People)为4 printf("%d\n",siz 阅读全文
posted @ 2010-09-25 23:46 再快一点 阅读(263) 评论(0) 推荐(0) 编辑
摘要: // Test0921.cpp : 定义控制台应用程序的入口点。//#include <iostream>using namespace std; void Fun1(){ char str[6]={'h','e','l','l','o'}; //这一句编译的时候会报错“数组界限溢出”(因为数组没有空间存储\0):char str[5]="hello"; //... 阅读全文
posted @ 2010-09-25 20:31 再快一点 阅读(342) 评论(0) 推荐(0) 编辑
摘要: 先看一段C的代码(注意,如果在vs中编译此代码,需要将后缀名设置为.c而不是.cpp,因为后缀名为c的话vs才会使用C的编译器)#include<stdio.h>intmain(intargc,constchar*argv[]){//在C语言中const修饰的是一个只读变量,并不是一个常量constintnum=99;//这一句会编译报错。因为ANSIC规定数组定义时维度必须是常量,只读变量也是不可以的//intarr[num];int*p=&num;//因为num的只读仅仅是编译的限制,所以可以通过指针的方式改变其值*p=123;//输出123,说明num被改变了prin 阅读全文
posted @ 2010-09-23 15:40 再快一点 阅读(974) 评论(0) 推荐(1) 编辑
摘要: #includestdio.hstruct 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) { printf("Cannot open file strike any key exit!"); } printf("\ninput data\n"); for(i=0;i2;i++,pp+ 阅读全文
posted @ 2010-09-17 16:32 再快一点 阅读(4797) 评论(0) 推荐(0) 编辑
摘要: C代码如下:#include "stdio.h"__declspec(dllexport) int Call(int (*qq)(int num),char * str){ printf(str); return qq(123);}多次验证发现在C#中传委托给C中的函数指针,如果委托不带参数则都能成功运行,但是委托一带参数不管是int参数还是string参数或者其他参数,都会报“尝试读取或写入受保护的内存。这通常指示其他内存已损坏”的错误,找了一天才找到解决方法,既在C#的委托声明上加[UnmanagedFunctionPointer(CallingConvention.Cdecl)],正确 阅读全文
posted @ 2010-09-17 14:43 再快一点 阅读(3793) 评论(1) 推荐(0) 编辑
摘要: 编写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 Main(string[] args) { MyFun(); } [DllImport("My.dll")] public ext 阅读全文
posted @ 2010-09-16 19:44 再快一点 阅读(2975) 评论(0) 推荐(0) 编辑
摘要: #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. */ currentPosition = ftell(fp); /* Jump to the end of the file. */ fseek( fp, 0L, SEEK_END ); / 阅读全文
posted @ 2010-09-14 23:15 再快一点 阅读(256) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 下一页