我有以下代码:
#define NUM_PEOPLE 20
#define TIME_PEOPLE 10
typedef struct
{
int name;
int age;
} People
typedef struct
{
int number;
int post;
} Contact;
typedef struct
{
int number;
Pepole people[TIME_PEOPLE][NUM_PEOPLE];
Contact contact[NUM_PEOPLE];
} Master;
typedef struct
{
int number;
People people[NUM_PEOPLE][NUM_PEOPLE];
Contact contact[NUM_PEOPLE];
} Info;
Info info;
Master master;
int counter = 1
int size;
int offset = 0;
while(counter > 0)
{
size = TIME_PEOPLE;
if(counter == 1)
{
size = NUM_PEOPLE - (TIME_PEOPLE * (offset + 1));
}
memcpy(&info.people[TIME_PEOPLE + TIME_PEOPLE * offset][0], &master.people[0][0],
sizeof(People) * size * NUM_PEOPLE);
offset ++;
counter --;
}
但我收到以下警告:
Warning 669: Possible data overrun for function 'memcpy(void *, const void *, unsigned int)', argument 3 ,
我制作了这段代码,因为NUM_PEOPLE
可以更改为小于TIME_PEOPLE
,那么这个警告是如何发生的以及如何修复它?
PS如果TIME_PEOPLE
改成8
,这意味着我们需要复制3次才能填满info