|  | 
 
| 
#include"stdio.h"
x
马上注册,结交更多好友,享用更多功能^_^您需要 登录 才可以下载或查看,没有账号?立即注册  #include"stdlib.h"
 #include"string.h"
 
 void GetMemory(char *p)
 {
 p = (char*)malloc(100);
 }
 void Text(void)
 {
 char *str = NULL;
 GetMemory(str);
 strcpy(str,"hello,world!");
 printf(str);
 }
 int main()
 {
 Text();
 }
 
 
 
 
 
 
 
复制代码#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <malloc.h>
#include <string.h>
void GetMemory(char** p) // <---------- 注意这里
{
    *p = (char*)malloc(100 * sizeof(char)); // <---------- 注意这里
}
int main()
{
    char* str = NULL;
    GetMemory(&str); // <---------- 注意这里
    strcpy(str, "hello, world!");
    printf("%s", str); // <---------- 注意这里
    free(str);
}
 | 
 |