二级指针
下面是使用二级指针分配内存的例子
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- void memorylocate(char **ptr)
- {
- *ptr=(char *)malloc(10*sizeof(char));
- }
- int main(int argc,char **argv)
- {
- char *buffer;
- memorylocate(&buffer);
- strcpy(buffer,"12345");
- printf("buffer %s\n",buffer);
- return 0;
- }