Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Ò»¸öc/c++º¯Êýµ÷ÓÃÕ»µÄʵÏÖ

º¯Êýµ÷ÓÃÕ»µÄʵÏÖ¡£¿ÉÓÃÓÚʵÏÖ¼òµ¥µÄ½Å±¾½âÊÍÆ÷¡£
ÉùÃ÷:
#pragma once
const int BUFFERSIZE = 1024;
const int growfactor = 2;
// this stack is used as call stack.
class TStack{
private:
size_t size;   // the stack length
size_t pos;   // the stack top position   
char *buffer;  // the buffer

private:
void push(void* D, size_t bytecount);  // the implementation of push
void* pop(size_t bytecount);  // the implementation of pop
public:
TStack(size_t _size = BUFFERSIZE, size_t _pos = 0);  // initialize
TStack(const TStack& o);  // copy
TStack& operator=(const TStack& o);  // assignment
void pushInt(int i) { push(&i, sizeof(int)); }  // push an int
void pushLong(long l) { push(&l, sizeof(long)); }  // push a long
void pushfloat(double f) { push(&f, sizeof(f));}  // push  a double
void pushPointer(void* p){ push(p, sizeof(p)); }
// int 
int popInt() { return *(int *)pop(sizeof(int));}  // pop an int
long popLong() { return *(long *)pop(sizeof(long)); }  // pop an int    
double* popfloat() { return (double*)pop(sizeof(double)); }  // pop a double
void* popPointer() { return pop(sizeof(void*)) ; }
void clear() { pos = 0; }  
};
ʵÏÖ£º
#include "stdafx.h"
#include "TStack.h"
#include "new.h"
void TStack::push( void* D, size_t bytecount )
{
// if memory is not enough
// if run under multithread envionment,
// a lock or critical section should be added
if (pos + bytecount > size)
{   
  size_t oldsize = size;
       size *= growfactor;   
  char *newbuffer = new char[size];
  memcpy(newbuffer, buffer, oldsize);
  delete buffer;
  buffer = newbuffer;   
}
memcpy(buffer+pos, D, bytecount);
pos += bytecount;
}
void* TStack::pop( size_t bytecount )
{
// need synchronization f


Ïà¹ØÎĵµ£º

mysql connect by c++

#include <stdio.h>
#include <windows.h>
#include <mysql.h>
#define host "localhost"
#define username "root"
#define password "123"
#define database "oa"
MYSQL *conn;
int main()
{
MYSQL_RES *res_set;
MYSQL_ROW row;
unsigned int i,ret;
FILE *fp;
MYSQL_FIELD *field; ......

Delphi Óë C/C++ Êý¾ÝÀàÐͶÔÕÕ±í

Delphi Óë C/C++ Êý¾ÝÀàÐͶÔÕÕ±í
DelphiÊý¾ÝÀàÐÍC/C++
ShorInt
8λÓзûºÅÕûÊý
char
Byte
8λÎÞ·ûºÅÕûÊý
BYTE,unsigned short
SmallInt
16λÓзûºÅÕûÊý
short
Word
16λÎÞ·ûºÅÕûÊý
unsigned short
Integer,LongInt
32λÓзûºÅÕûÊý
int,long
Cardinal,LongWord/DWORD
32λÎÞ·ûºÅÕûÊý
unsigned long
Int6 ......

CÖÐÈçºÎµ÷ÓÃC++º¯Êý

CÖÐÈçºÎµ÷ÓÃC++º¯Êý?
 
ǰÕó×Ó±»Îʼ°Ò»¸öÔÚCÖÐÈçºÎµ÷ÓÃC++º¯ÊýµÄÎÊÌ⣬µ±Ê±¼òµ¥»Ø´ðÊǽ«º¯ÊýÓÃextern "C"ÉùÃ÷£¬µ±±»Îʼ°ÈçºÎ½«ÀàÄÚ³ÉÔ±º¯ÊýÉùÃ÷ʱ£¬Ò»Ê±ÓïÈû£¬ºóÀ´ÍøÉϲéÁËÏ£¬ÍøÉÏÓÐÒ»·­ÒëC++Ö®¸¸µÄÎÄÕ¿ÉÒÔ×÷Ϊ½â´ð£¬ËìÄÃÀ´Markһϡ£
 
½« C++ º¯ÊýÉùÃ÷Ϊ``extern "C"''£¨ÔÚÄãµÄ C++ ´úÂëÀï×öÕâ¸öÉùÃ÷£©£¬ ......

C/C++ ʵÏÖÎļþ͸Ã÷¼Ó½âÃÜ

Çë¼û´úÂëÏêϸעÊÍ
//  ÐÞ¸´Éæ¼°ºóÊÓÁбíµÄWin2K¼æÈÝÐÔ
//  Fixes Win2K compatibility regarding lookaside lists.
//
#ifndef _WIN2K_COMPAT_SLIST_USAGE // Add content(Ôö¼ÓÄÚÈÝ)
#define _WIN2K_COMPAT_SLIST_USAGE 
#endif
#include "ntifs.h"
#include "ntdddisk.h"
//
// ÔÚ´úÂëÖпªÆ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ