Hi all,
The following program is compiled using gcc with "-W" option. GCC is
giving the following warning message
initStructElem. c: In function `main':
initStructElem. c:20: warning: missing initializer
initStructElem. c:20: warning: (near initialization for `str1.f')
Here is the program
1 #include <stdio.h>
2
3 int main(void)
4 {
5 typedef struct
6 {
7 int i1;
8 float f1;
9 }str_1t;
10
11 typedef struct
12 {
13 int i;
14 float f;
15 char c;
16 int *pi;
17 str_1t s2;
18 }str_t;
19
20 str_t str1={0};
21
22 printf("str1.i= %d\t str1.f=%f\t str1.c=%d\t
str1.pi=%p\n",s tr1.i,str1 .f,str1.c,str1. pi);
23 printf("str1.s2 .i1=%d\n",str1. s2.i1);
24 return 0;
25 }
Please let me know why gcc is complaining.
Is this not a standard of way of intializing structure fields?
The following program is compiled using gcc with "-W" option. GCC is
giving the following warning message
initStructElem. c: In function `main':
initStructElem. c:20: warning: missing initializer
initStructElem. c:20: warning: (near initialization for `str1.f')
Here is the program
1 #include <stdio.h>
2
3 int main(void)
4 {
5 typedef struct
6 {
7 int i1;
8 float f1;
9 }str_1t;
10
11 typedef struct
12 {
13 int i;
14 float f;
15 char c;
16 int *pi;
17 str_1t s2;
18 }str_t;
19
20 str_t str1={0};
21
22 printf("str1.i= %d\t str1.f=%f\t str1.c=%d\t
str1.pi=%p\n",s tr1.i,str1 .f,str1.c,str1. pi);
23 printf("str1.s2 .i1=%d\n",str1. s2.i1);
24 return 0;
25 }
Please let me know why gcc is complaining.
Is this not a standard of way of intializing structure fields?
Comment