will it initialize all the variable in structure to spaces?Code:struct X
{
char a[10];
char b[10];
};
struct X x;
memset(&x,0x20,sizeof(x));
Printable View
will it initialize all the variable in structure to spaces?Code:struct X
{
char a[10];
char b[10];
};
struct X x;
memset(&x,0x20,sizeof(x));
will it initialize all the variable in structure to spaces?Code:struct X
{
char a[10];
char b[10];
};
struct X x;
memset(&x,0x20,sizeof(struct X));
Yes, but it will not add any '\0' so a & b are still invalid strings.
Not with a single memset, no. Not any easier than just either doing it in the first place by hand, or by calling strncpy or something.Code:struct foo bar = { "...9 spaces...", "...9 spaces..." };
Quzah.