测试源码:

 

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

char *get_str()
{
	char *tmp = (char *)malloc(100);
	if (tmp == NULL)
	{
		return NULL;
	}

	strcpy(tmp, "AABBCCDDEEFF");

	return tmp;
}



int main(void)
{
	char buf[128] = { 0 };

	char *p = NULL;
	p = get_str();
	if (p != NULL)
	{
		printf("p = %s\n", p);

		free(p);
		p = NULL;

	}
	printf("\n");
	system("pause");
	return 0;
}

 

测试结果:

内存四区——堆区分析 

 

测试分析:

内存四区——堆区分析

 

 

 

相关文章:

  • 2022-12-23
  • 2021-11-20
  • 2021-11-20
  • 2022-12-23
  • 2021-05-23
  • 2021-06-27
  • 2022-12-23
  • 2022-01-10
猜你喜欢
  • 2021-12-30
  • 2021-05-08
  • 2021-05-09
  • 2021-06-22
  • 2021-11-20
相关资源
相似解决方案