S
sathyashrayan
The standard confirms that the following initialization of a struct
struct node
{
---
---
}
struct node var[3] = {NULL};
My doubts are followed:
1) When I set the high warning level of the compiler (-Wall) that
gives some warnings. What are those warnings?
2) Is there any difference in the above initialization if I declare
the struct's first element as a value or a pointer? Does this have any
impact on the usage of NULL pointer in
the above context of initialization?
#include <stdio.h>
struct node
{
int a;
char *b;
};
int main(void)
{
struct node var[3] = {NULL} ; /*a is not a pointer.So is this
initialization correct*/
printf("%s %d\n",var[0].b,var[0].a);
var[0].b = "sathya";
var[0].a = 10;
printf("%s %d\n",var[0].b,var[0].a);
return 0;
}
My understanding of the var variable is this
"var is a array of 4 elements in which all the 4 elements are set
to NULL"
So with a single initialization all the array's value is set to be
NULL?
Is there any wrong understanding?
3)I searched the above questions in the faq but I don't get the
exacat one.Is it in the faq?
The above questions is based on a thread named "NULL pointer and zero
value"
in clc.
struct node
{
---
---
}
struct node var[3] = {NULL};
My doubts are followed:
1) When I set the high warning level of the compiler (-Wall) that
gives some warnings. What are those warnings?
2) Is there any difference in the above initialization if I declare
the struct's first element as a value or a pointer? Does this have any
impact on the usage of NULL pointer in
the above context of initialization?
#include <stdio.h>
struct node
{
int a;
char *b;
};
int main(void)
{
struct node var[3] = {NULL} ; /*a is not a pointer.So is this
initialization correct*/
printf("%s %d\n",var[0].b,var[0].a);
var[0].b = "sathya";
var[0].a = 10;
printf("%s %d\n",var[0].b,var[0].a);
return 0;
}
My understanding of the var variable is this
"var is a array of 4 elements in which all the 4 elements are set
to NULL"
So with a single initialization all the array's value is set to be
NULL?
Is there any wrong understanding?
3)I searched the above questions in the faq but I don't get the
exacat one.Is it in the faq?
The above questions is based on a thread named "NULL pointer and zero
value"
in clc.