这段C代码编译运行后为什么会有乱码出现?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
typedef struct
{
uint8_t datetime[6];
uint32_t len;
uint8_t* data;
}DATA_T;
DATA_T data11;
void supp_data_save()
{
size_t Return;
int i;
uint8_t data1[64] = { 0 };
uint8_t* buf;
memset(&data11, 0, sizeof(data11));
buf = (uint8_t*)malloc(10);
memcpy(data11.datetime, "202207\0", 6);
data11.len = 1;
memcpy(buf, "1233211231\0", 10);
data11.data = buf;
printf("data11: %c\r\n", data11.data[0]);
printf("data11: %c\r\n", data11.data[1]);
printf("data11: %c\r\n", data11.data[2]);
printf("==============================\n");
for (i = 0; i < 10; i++)
{
printf("%c", data11.data[i]);
}
printf("\r\n00\r\n");
printf("==============================\n");
int len1 = (sizeof(data11) + 10 - 1);
memcpy(data1, &data11, len1);
for (i = 0; i < 10; i++)
{
printf("%c", data1[i]);
}
printf("\r\n");
printf("==============================\n");
printf("data111: %c\r\n", data11.data[10]);
printf("data111: %c\r\n", data11.data[11]);
printf("data111: %c\r\n", data11.data[12]);
printf("\r\n000\r\n");
}
int main()
{
supp_data_save();
return 0;
}