c/c++µÄ֪ʶµãÊÕ¼¯
1.¶¯Ì¬»ñµÃÄÚ´æµÄ´úÂë:
void GetMemory(char **p, int num)
{
*p = (char *)malloc(sizeof(char) * num);
}
char* GetMemory2(int num)
{
char* p = (char *)malloc(sizeof(char) * num);
return p;
}
------------------------------------------
´íÎóµÄ´úÂë:
void GetMemory3(char *p, int num)
{
p = (char *)malloc(sizeof(char) * num);
}///////////////´íÎóÔÚÄÄÀï,ÎҾͲ»Ëµ,×Ô¼ºÈ¥²é.
2.strcpy()µÄ´úÂë:
char* strcpy(char* strDest,const char* strSrc)
{
if(strDest==NULL || strSrc==NULL) return NULL;
char* pStr=strDest;
while((*strDest++=*strSrc++)!='\0)
NULL;
return pStr;
}
3.memcpy()µÄ´úÂë:
void* memcpy(char* strDest,const char* strSrc,size_t size)
{
if(strDest==NULL||strSrc==NULL) return NULL;
if(size <=0) return NULL;
char* pStr=strDest;
while(size-->0)
*strDest++=*strSrc++;
return pStr;
}
4.¹ØÓÚsizeof²Ù×÷·û:
char 1
short 2
short int 2
signed short 2
unsigned short 2
int 4
long
Ïà¹ØÎĵµ£º
VB
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
MSComm1.CommPort = i1
MSComm1.PortOpen = True
MSComm1.InputMode = comInputModeBinary
MSComm1.InBufferCount = 0
& ......
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include ".\sqlite3_lib\sqlite3.h"
static int _callback_exec(void * notused,int argc, char ** argv, char ** aszColName)
{
int i;
for ( i=0; i<argc; i++ )
......
C/C++ÊÇ×îÖ÷ÒªµÄ±à³ÌÓïÑÔ¡£ÕâÀïÁгöÁË50ÃûÓÅÐãÍøÕ¾ºÍÍøÒ³Çåµ¥£¬ÕâЩÍøÕ¾Ìṩc/c++Ô´´úÂë ¡£Õâ·ÝÇåµ¥ÌṩÁËÔ´´úÂëµÄÁ´½ÓÒÔ¼°ËüÃǵÄС˵Ã÷¡£ÎÒÒѾ¡Á¦°üÀ¨×î¼ÑµÄC/C++Ô´´úÂëµÄÍøÕ¾¡£Õâ²»ÊÇÒ»¸öÍêÕûµÄÇåµ¥£¬ÄúÓн¨Òé¿ÉÒÔÁªÏµÎÒ£¬ÎÒ½«»¶ÓÄúµÄ½¨ Ò飬ÒÔ½øÒ»²½¼ÓÇ¿Õâ·½ÃæµÄÇåµ¥¡£
1¡¢http://snippets.dzone.com/tag/c/ --ÊýÒÔǧ ......
Ò»£¬²»Í¬¹Ø¼ü×Ö£¬ÏµÍ³Ñ¹Õ»·½Ê½
1£¬Èç¹ûº¯ÊýfuncÊÇ__cdecl(VCϵÄĬÈϵ÷Ó÷½Ê½)£¬µ÷ÓÃʱÇé¿öÈçÏÂ
int main()
{
//²ÎÊý´ÓÓÒµ½×óѹջ
push 4
push 3
push 2
push 1
call func
add esp 0x10 //µ÷ÓÃÕ߻ָ´¶ÑÕ»Ö¸Õëesp£¬4¸ö²ÎÊýµÄ´óСÊÇ0x10(4x4)
}
Cµ÷ÓÃÔ¼¶¨£¨¼´ÓÃ__cdecl¹Ø¼ü×Ö˵Ã÷£©°´´ÓÓÒÖÁ×óµÄ˳Ðòѹ² ......