【发布时间】:2016-05-20 08:15:17
【问题描述】:
#include <stdio.h>
#include <string.h>
#define PIPE "myPipeName"
typedef enum
{
ID1,
ID2
}TEST_ID;
typedef struct
{
double dCnt;
TEST_ID id ;
}Response;
int main()
{
char pipeName[256]=PIPE;
Response res[2];
printf("1. pipeName : %s , PIPE : %s\n",pipeName,PIPE);
memset(res,0,2*sizeof(res));
printf("2. pipeName : %s , PIPE : %s\n",pipeName,PIPE);
return 0;
}
实际输出:
- 管道名称:我的管道名称,管道:我的管道名称
- 管道名称:,管道:我的管道名称
预期 o/p:
- 管道名称:我的管道名称,管道:我的管道名称
- 管道名称:我的管道名称,管道:我的管道名称
请告诉我如何解决这个问题?
【问题讨论】:
-
2*sizeof(res)...hmmm.. -
谢谢。今天我似乎失去了常识..但我不知道你们为什么投反对票。
标签: c++ c arrays sizeof memset