IT老鸟,信息安全硕士。
分类: C/C++
2011-10-22 15:21:31
指针也是值传递.这样才能改值.
#include "process.h"
#include "string.h"
#include "stdlib.h"
void testmemory(char **ptr){
*ptr=(char*)malloc(sizeof(char)*256);
printf("strlen(ptr)=%d\n",strlen(*ptr));
//return ptr;
}
int main(int argc, char* argv[])
{
char* ptr1;
char a[100];
testmemory(&ptr1);
printf("strlen(ptr1)=%d\n",strlen(ptr1));
free(ptr1);
system("PAUSE");
return 0;
}
blacksapper2011-11-06 15:51:51
chenliangmoran2011-11-03 11:04:49
blacksapper2011-11-02 14:39:56
chenliangmoran2011-11-01 17:40:40