随笔分类 - C/C++
摘要:这是一个简单的c++爬虫,效率并不是很高... 1 #include 2 int s1[1000000],s2[1000000]; 3 void fun(int a, int b) 4 { 5 int i,ii; 6 bool t1,t2,t3,t4; 7 s1[0] = s...
阅读全文
摘要:这是一个关于C++指针的问题,思考了一下void GetMemory(char *p, int num){ p = (char*) malloc (sizeof(char) * num);}void Test(void) { char *str = NULL; GetMemory(str,100);//str 仍为NULL strcpy(str, "hello"); //运行错误}这个p等同于指针值传递,只是将p的值传递进去,然后申请内存编译器会为函数每个参数制作临时副本,p的副本_p = p;如果函数体修改了_p的内容,就导致p的内容也相应修改。如果不修改_p,p也不变。
阅读全文

浙公网安备 33010602011771号