二级指针 分配内存

    #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
",buffer);  
            return 0;  
    }  

转自 http://blog.csdn.net/geekcome/article/details/7220688

原文地址:https://www.cnblogs.com/marky/p/3729898.html