69,369
社区成员
发帖
与我相关
我的任务
分享
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<Windows.h>
void GetMemory(char **p, int num)
{
*p = (char *)malloc(num);
}
int main()
{
char *str = NULL;
GetMemory(&str, 100);
strcpy(str, "hello world!");
printf(str);
printf("\n");
system("pause");
return 0;
}
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<Windows.h>
void GetMemory(char *p)
{
p = (char *)malloc(100);
}
int main()
{
char *str = NULL;
GetMemory(str);
strcpy(str, "hello world!");
printf(str);
printf("\n");
system("pause");
return 0;
}
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<Windows.h>
void GetMemory(char *p)
{
p = (char *)malloc(100);
strcpy(p, "hello world!");
printf(p);
}
int main()
{
char *str = NULL;
GetMemory(str);
printf("\n");
system("pause");
return 0;
}
结果:
hello world!
请按任意键继续. . .
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<Windows.h>
void GetMemory(char *p)
{
p = (char *)malloc(100);
}
int main()
{
char *str = NULL;
printf("\n");
system("pause");
return 0;
}
谁说的,你自己看。#include<stdio.h>
#include<string.h>
#include<stdlib.h>
char *GetMemory(char *p)
{
p = (char *)malloc(100);
return p;
}
int main()
{
char *str = NULL;
str=GetMemory(str);
strcpy(str, "hello world!");
printf(str);
printf("\n");
free(str);
system("pause");
return 0;
}
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
char *GetMemory(char *p)
{
p = (char *)malloc(100);
return p;
}
int main()
{
char *str = NULL;
str=GetMemory(str);
strcpy(str, "hello world!");
printf(str);
printf("\n");
system("pause");
return 0;
}