1.malloc/free VS new/delete
http://blog.csdn.net/hackbuteer1/article/details/6789164
注意以下代码:
string *psa=new string[10]; //call the default constructor
int *pia=new int[10]; // no initialization
int *pia2=new int[10](); //ok, initialize the element 0
int *pia3=new int[10](5); //error
动态分配数组时,如果数据元素就有类类型,将使用该类的默认构造函数实现初始化,如果数组元素是内置类型,则无初始化,也可以使用跟在数组长度后的一对空圆括号,对数组元素做初始化,但是不能赋其它值
2.GET VS POST
http://blog.csdn.net/gideal_wang/article/details/4316691
http://www.yining.org/2010/05/04/http-get-vs-post-and-thoughts/
http://www.cnblogs.com/ouzi/archive/2012/10/16/2726778.html
注意:post并没有比get安全,因为两者都是明文传输的,get请求参数通过url来发送,post则通过http包的包体提交数据
3.sizeof(enum) VS sizeof(union) VS sizeof(struct) VS sizeof(class)
注意sizeof()和strlen(),参考本博客文章:小心笔试中的小陷阱(一)条目1:http://blog.csdn.net/moubao/article/details/9283695
sizeof(enum):参考本博客文章:static const VS const VS enum:http://blog.csdn.net/moubao/article/details/10408887
sizeof(union):参考本博文章:小心笔试中的小陷阱(一)条目11:http://blog.csdn.net/moubao/article/details/9283695
sizeof(struct)和sizeof(class)会有内存对齐,这个就是老生常谈了。。。参考本博客文章:
4.typedef struct 指针
有时我们会看到以下代码:
typedef struct BinaryTreeNode
{
int data;
BinaryTreeNode* pointer;
}*pNode;
上述代码的含义是将struct BinaryTreeNode* typedef 为 pNode,即 BinaryTreeNode* p等价于 pNode p;注意,在将
struct BinaryTreeNode* typedef 为 pNode之前,在结构体中不能用 pNode pointer,但是可以用上述形式,或者用以下形式:
typedef struct BinaryTreeNode *pNode;
struct BinaryTreeNode {
int data;
pNode pointer;
};
5.*p++ VS *++p
*p++先取得*p,然后再p=p+1;*++p先p=p+1,然后*p
6.NULL
要想使用NULL,需要包含头文件<cstddef>哦
7.char* number
对于number可以使用number[i],也可以有strlen(number),不过使用strlen(),需要包含头文件cstring
8.memset()函数:
格式:
void *memset( void *dest, int c, size_t count );其头文件是<memory.h>
9.printf() 头文件:<stdio.h>
以下10-12可以参考本博客文章:http://blog.csdn.net/moubao/article/details/10308539
10.内排序 VS 外排序
内排序:指在排序期间数据对象全部存放在内存的排序。
外排序:指在排序期间全部对象太多,不能同时存放在内存中,必须根据排序过程的要求,不断在内,外存间移动的排序。
根据排序元素所在位置的不同,排序分:
内排序:在排序过程中,所有元素调到内存中进行的排序,称为内排序。内排序是排序的基础。内排序效率用比较次数来衡量。按所用策略不同,内排序又可分为插入排序、选择排序、交换排序、归并排序及基数排序等几大类。
外排序:在数据量大的情况下,只能分块排序,但块与块间不能保证有序。外排序用读/写外存的次数来衡量其效率。
11.归并排序 VS 快速排序
与快速排序相比,归并排序的最大特点是,它是一种稳定的排序方法。归并排序一般多用于外排序。但它在内排方面也占有重要地位,因为它是基于比较的时间复杂度为O(N*Log(N))的排序算法中唯一稳定的排序,所以在需要稳定内排序时通常会选择归并排序。归并排序不要求对序列可以很快地进行随机访问,所以在链表排序的实现中很受欢迎。
12.稳定排序 VS 不稳定排序
选择排序、快速排序、希尔排序、堆排序不是稳定的排序算法,而冒泡排序、插入排序、归并排序和基数排序是稳定的排序算法
char *strstr( const char *str, const char *strSearch ); // C only 返回strSearch第一次在str中出现的位置
char *strcpy( char *strDestination, const char *strSource ); 将strSource复制到strDestination