代码拉取完成,页面将自动刷新
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "mem.h"
typedef struct _buff_st_1
{
int data_len;
char data[0];
}buff_st_1;
typedef struct _buff_st_2
{
int data_len;
char *data;
}buff_st_2;
typedef struct _buff_st_3
{
int data_len;
char data[];
}buff_st_3;
int main()
{
int n1 = sizeof(buff_st_1);
int n2 = sizeof(buff_st_2);
int n3 = sizeof(buff_st_3);
buff_st_1 *buff1 = (buff_st_1 *)malloc(sizeof(buff_st_1)+100);
buff_st_2 *buff2 = (buff_st_2 *)malloc(sizeof(buff_st_2));
buff_st_3 *buff3 = (buff_st_3 *)malloc(sizeof(buff_st_3)+50);
int n = show_memory();
strncpy(buff1->data,"hello",100);
printf("buff1 address:%p,buff1.data_len address:%p,buff1.data address:%p,value:%s\n",
buff1, &(buff1->data_len), buff1->data,buff1->data);
buff2->data = (char*)malloc(10);
printf("buff2 address:%p,buff2.data_len address:%p,buff2.data address:%p\n",
buff2, &(buff2->data_len), buff2->data);
strncpy(buff3->data,"world",100);
printf("buff3 address:%p,buff3.data_len address:%p,buff3.data address:%p,value:%s\n",
buff3, &(buff3->data_len), buff3->data,buff3->data);
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。