0

Why static variables are initialized by only constant? Why we can't initialized it by a other variables?

https://code.sololearn.com/cJaVLyUklS34/?ref=app

4th Jan 2020, 6:39 AM
VEERESH MAURYA
VEERESH MAURYA - avatar
3 Respuestas
0
What do you mean? #include <stdio.h> int main() { static int p; int c = 12; p = c; printf("%d", p);//12 return 0; }
4th Jan 2020, 6:47 AM
Akib
Akib - avatar
0
if we use - int c=12; static int p=c; // Compiling error
4th Jan 2020, 6:50 AM
VEERESH MAURYA
VEERESH MAURYA - avatar
0
Do this- int c = 12; static int p; p = c; You have to declare static first then initialize it.
4th Jan 2020, 6:53 AM
Akib
Akib - avatar