相关疑难解决方法(0)

memset没有填充数组

 u32 iterations = 5;
 u32* ecx = (u32*)malloc(sizeof(u32) * iterations);

 memset(ecx, 0xBAADF00D, sizeof(u32) * iterations);
 printf("%.8X\n", ecx[0]);

 ecx[0] = 0xBAADF00D;
 printf("%.8X\n", ecx[0]);

 free(ecx);
Run Code Online (Sandbox Code Playgroud)

非常简单地说,为什么我的输出如下?

0D0D0D0D
BAADF00D
Run Code Online (Sandbox Code Playgroud)

ps:u32是unsigned int的简单typedef

编辑:

  • 用gcc 4.3.4编译
  • string.h包含在内

c memset

4
推荐指数
1
解决办法
2947
查看次数

标签 统计

c ×1

memset ×1