骑在牛背上看书

关注

GetMemory(char **p, int num)

骑在牛背上看书

关注

阅读 68

2023-06-17


#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void GetMemory(char **p, int num)
{
	*p = (char *)malloc(num);
 } 

void Test(void)
{ 
	char *str = NULL;
	GetMemory(&str, 100); 
	strcpy(str, "hello\n"); 
	printf(str); 
	free(str); 
} 
//请问运行Test 函数会有什么样的结果?

void main()
{
	Test();
}
/*
hello
Press any key to continue
*/



相关推荐

云竹文斋

关于 const char* p , char const* p 以及 char * const p

云竹文斋 96 0 0

7dcac6528821

private static int num=0;

7dcac6528821 72 0 0

at小涛

R语言num转化为int

at小涛 30 0 0

以前干嘛去了

int main(int argc,char *argv[])参数说明

以前干嘛去了 189 0 0

陆佃

SQL server int 转char类型

陆佃 147 0 0

豆丁趣

python列名改成char,int,float

豆丁趣 29 0 0

西红柿上校

narrowing conversion of 'XXX' from 'int' to 'char' inside{}

西红柿上校 98 0 0

雨鸣静声

narrowing conversion of ‘XXX‘ from ‘int‘ to ‘char‘inside{}

雨鸣静声 172 0 0

水沐由之

main(int argc,char *argv[]),参数运用

水沐由之 118 0 0

天使魔鬼

用int和char来接收汉字

天使魔鬼 59 0 0

精彩评论(0)

0 0 举报