J
jammie_linux
Recently I came across a code which is quite similar to one shown
below:
#include <stdio.h>
#include <string.h>
typedef struct node
{
int data;
int arr[10];
struct node *next;
} node;
int main(void)
{
node block;
memset( &block, 0 , sizeof(block) );
printf("Main exiting...\n");
return 0;
}
In the above code, the memset function will make the "sizeof(block)
elements" in memory being pointed by &block equal to zero. But, isn't
the memset function overwriting the memory being pointed by &block
since the memory beyond the one being pointed by &block might be
belonging to something else?
Please help me to pin-point my mistake.
below:
#include <stdio.h>
#include <string.h>
typedef struct node
{
int data;
int arr[10];
struct node *next;
} node;
int main(void)
{
node block;
memset( &block, 0 , sizeof(block) );
printf("Main exiting...\n");
return 0;
}
In the above code, the memset function will make the "sizeof(block)
elements" in memory being pointed by &block equal to zero. But, isn't
the memset function overwriting the memory being pointed by &block
since the memory beyond the one being pointed by &block might be
belonging to something else?
Please help me to pin-point my mistake.