A
Arun
Hi all,
The code below gives compilation error (in gcc).
"initializer element is not constant" @line 11
1 #include <stdio.h>
2 char* ptr="string";
3 //char ptr[ ]="string";
4
5 typedef struct
6 {
7 char *c;
8 int i;
9 }test_struct;
10
11 test_struct s={ptr,10};
12
13
14 int main()
15 {
16
17 return 0;
18 }
But when comment Line 2 & uncomment line 3 it works fine. It also
works fine when i move line 11 into main function.
Can anybody tell me cause of this error.
Thanks,
Arun
The code below gives compilation error (in gcc).
"initializer element is not constant" @line 11
1 #include <stdio.h>
2 char* ptr="string";
3 //char ptr[ ]="string";
4
5 typedef struct
6 {
7 char *c;
8 int i;
9 }test_struct;
10
11 test_struct s={ptr,10};
12
13
14 int main()
15 {
16
17 return 0;
18 }
But when comment Line 2 & uncomment line 3 it works fine. It also
works fine when i move line 11 into main function.
Can anybody tell me cause of this error.
Thanks,
Arun