Overblog Tous les blogs Top blogs Technologie & Science Tous les blogs Technologie & Science
Suivre ce blog Administration + Créer mon blog
MENU

c-c++

strcpy() destination is not enough

1 Mai 2013 Publié dans #c-c++

char *array1 = "Happy Birthday to You"; char array3[1]; strcpy(array3,array1); cout<

Lire la suite
Publicité

vetor list 区别

25 Avril 2013 Publié dans #c-c++

vector和数组类似,它拥有一段连续的内存空间,并且起始地址不变,因此它能非常好的支持随机存取(即使用[]操作符访问其中的元素),但由于它的内存空间是连续的,所以在中间进行插入和删除会造成内存块的拷贝(复杂度是O(n)),另外,当该数组后的内存空间不够时,需要重新申请一块足够大的内存并进行内存的拷贝。这些都大大影响了vector的效率。 list是由数据结构中的双向链表实现的,因此它的内存空间可以是不连续的。因此只能通过指针来进行数据的访问,这个特点使得它的随机存取变的非常没有效率,需要遍历中间的元素,搜索复杂度O(n),因此它没有提供[]操作符的重载。但由于链表的特点,它可以以很好的效率支持任意地方的删除和插入。...

Lire la suite

Basic knowledge C/C++ (2)

15 Mars 2013 Publié dans #c-c++

Difference between C++ and java Java runs in a virtual machine C++ supports unsigned arithmetic C++ allows operator overriding C++ àmultiple inheritance of class Java has a build-in garbage collection In java, parameters are always passed by value C++...

Lire la suite

Basic knowledge C/C++ (1)

2 Mars 2013 Publié dans #c-c++

1. storage qualifiers Volatile : keyword for variables, the value will change every time we use it, we should read the value in the memory. const: cannot be changed 2.static: 2.1 for variable: it means the value cannot be changed when the function/method...

Lire la suite
Publicité

数组总结 c++

18 Février 2013 Publié dans #c-c++

char a [5];分别是a[0],a[1],a[2],a[3],a[4]。 char name[]=”Ray Krebbs”; char name[11]=”Ray Krebbs”;系统将自动在字符串末尾添上结束标志’\0’。 数组初始化时,用作初始化的数组元素值放在一个大括号{}中,例如: int a[3]={ 1, 1, l }; //含三个元素的整型数组,元素的值都是1。 int b[5]={1, 2, 3 }; //可以只给部分(本例为前3个元素)赋值。 int a[]={1, 1,...

Lire la suite

convert TCHAR * to char *

3 Février 2013 Publié dans #c-c++

Windows Data Types for Strings (Windows) : int wstrlen(_TCHAR * wstr) { int l_idx = 0; while (((char*)wstr)[l_idx] != 0) l_idx += 2; return l_idx; } char *wstrdup(_TCHAR *wSrc) { int l_idx = 0; int l_len = wstrlen(wSrc); char *l_nstr = (char *)malloc(l_len);...

Lire la suite

convert int to char

24 Janvier 2013 Publié dans #c-c++

int a = 125; int b[50]; sprintf (b‚ "%d"‚ a); /* b contient la chaine "125"‚ et on concactene "oui". */ strcat (b‚ "oui"); printf ("%s\n"‚ b); ATTENTION : the first parameter of the fonction sprintf should be char[]

Lire la suite

Creation and use the DLL in Visual Studio

17 Janvier 2013 Publié dans #c-c++, #library

We will, in the article, see some examples for creating and using the DLL in VS. What's DLL? Dynamic-link library , or DLL, is Microsoft's implementation of the shared library concept in the Microsoft Windows and OS/2 operating systems. These libraries...

Lire la suite
Publicité

Using C++ library in C code

14 Janvier 2013 Publié dans #c-c++

extern “C” can help you to call c fonction from c++, and also it can help you do the reverse. But as we know c++ has class which we cannot use in c, so we have to do some wrapper to help us. 1. //code in add.cxx 2. #include "add.h" 3. int sample::method()...

Lire la suite

C/C++中static关键字详解

2 Janvier 2013 Publié dans #c-c++

http://www.cnblogs.com/yc_sunniwell/archive/2010/07/14/1777441.html 静态变量作用范围在一个文件内,程序开始时分配空间,结束时释放空间,默认初始化为0,使用时可以改变其值。 静态变量或静态函数只有本文件内的代码才能访问它,它的名字在其它文件中不可见。 用法1:函数内部声明的static变量,可作为对象间的一种通信机制 如果一局部变量被声明为static,那么将只有唯一的一个静态分配的对象,它被用于在该函数的所有调用中表示这个变量。这个对象将只在执行线程第一次到达它的定义使初始化。...

Lire la suite
1 2 > >>