#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