易截截图软件、单文件、免安装、纯绿色、仅160KB

c版本与c++版本的动态数组代码

C版本:
vim stash.h
#ifndef STASH_H
#define STASH_H
typedef struct STASHTag {
  int size;  /* Size of each space */
  int quantity; /* Number of storage spaces */
  int next; /* Next empty space */
  /* Dynamically allocated array of bytes: */
  unsigned char* storage;
} Stash;
void initialize(Stash* S, int Size);
void cleanup(Stash* S);
int add(Stash* S, void* element);
void* fetch(Stash* S, int index);
int count(Stash* S);
void inflate(Stash* S, int increase);
#endif //STASH_H
vim stash.c
/* Error testing macros: */
#include <assert.h>
/* Dynamic memory allocation functions: */
#include <stdlib.h>
#include <string.h> /* memcpy() */
#include <stdio.h>
#include "stash.h"
#define STEP 10
void initialize(Stash* S, int Size) {
  S->size = Size;
  S->quantity = 0;
  S->storage = 0;
  S->next = 0;
}
void cleanup(Stash* S) {
  if(S->storage) {
     puts("freeing storage");
     free(S->storage);
  }
}
int add(Stash* S, void* element) {
  /* enough space left? */
  if(S->next >= S->quantity)
    inflate(S, STEP);
  /* Copy element into storage,
  starting at next empty space: */
  memcpy(&(S->storage[S->next * S->size]),
      element, S->size);
  S->next++;
  return(S->next - 1); /* Index number */
}
void* fetch(Stash* S, int index) {
  if(index >= S->next || index < 0)
    return 0;  /* Not out of bounds? */
  /* Produce pointer to desired element: */
 // return &(S->storage[index * S->size]);
  return (S->storage+index*S->size);
}
int count(Stash* S) {
  /* Number of elements in stash */
  return S->next;
}
void inflate(Stash* S, int increase) {
  void* v =
    realloc


相关文档:

C/C++语法知识:typedef struct用法详解

    typedef为C语言的关键字,作用是为一种数据类型定义一个新名字。当typedef与结构结合使用时,会有一些比较复杂的情况,而且在C语言和C++里面略有差别,本文将详细讲解typedef struct的用法。
第一章    typedef struct 与 struct的区别
1.  基本解释
    ty ......

关于AES算法 JAVA同C++互解(AES)

关于加解密JAVA一般使用的JCE,关于C++可以实现AES加解密的开源项目就多的数不胜数的。
理论上上算法一样,对称密钥一样就能够互相识别了。
相信很多人开始想法都同我一样,起初我JAVA用JCE,C++使用openssl。
结果发现加密出的密文完全不相同。
出现问题就要解决
了解了一下JCE:
      JC ......

关于char * c="hello"与char c[]="hello"的区别

char * c = "hello"; c是个分配在堆栈中的一个变量。里面装的是字符串hello的首地址,而hello是常量区。PE文件在编译的时候就确定了的。
char []c = "hello";
"hello"是放在堆栈中保存的,跟上面的那个例子不同,由于hello是堆栈中的所以是可以修改的。而常量区里的是不可以修改的。因为PE的内存页属性是只读的。当然可以 ......

C键盘钩子

根据《Windows环境下32位汇编语言程序设计》(罗云彬著)书上的例子,采用SDK实现键盘记录器!
main.c
#include <windows.h>
#include "resource.h"
#define DEBUG 0
LRESULT CALLBACK HookKeyboardPro(int code,WPARAM wParam,LPARAM lParam);
BOOL CALLBACK ProcDlgMain(HWND hwndDlg,UINT uMsg,WPARAM wParam ......

简述C和C++程序员学习历程

简述C和C++程序员学习历程
收藏



< type="text/javascript">
document.body.oncopy = function() {
if (window.clipboardData) {
setTimeout(function() {
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号