Consider the below structure
struct A
{
int len;
int wid;
int size;
};
void main()
{
struct A var;
memset(&var,10,sizeof(struct A));
printf("value of len is %d\n",var.len);
}
When I run the program, I was expecting that all the structure members will get initialized with 10 but it didn't happened. It was printing some junk value
But when I do memset with 0 or memset with 1 it works.
memset(&var,0,sizeof(struct A));
printf("value of len is %d\n",var.len);
Can someone please explain this behavior of memset