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

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   


相关文档:

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; ......

C++中使用sqlite

#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++ )
   ......

SQLite C/C++接口介绍

这篇文章是使用SQLite C/C++接口的一个概要介绍和入门指南。
由于早期的SQLite只支持5个C/C++接口,因而非常容易学习和使用,但是随着SQLite功能的增强,新的C/C++接口不断的增加进来,到现在有超过150个不同的API接口。这往往使初学者望而却步。幸运的是,大多数SQLite中的C/C++接口是专用的,因而很少被使用到。尽管有这 ......

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 语言数据对齐

#include <stdio.h>    
struct Foo1
{
   char a;
   int  b;
   char c;
   int  d;
};
#pragma pack (2)
struct Foo2
{
   char a;
   int  b;
   char c;
   int  d; ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号