+ 1
why it prints 1......
#include<stdio.h> void main() { static main; int a; a=printcall(main); printf("%d\n",a); } int printcall(int addr){ addr++; return addr; } can anyone explain what does static main means ? while execute the above program it prints 1
1 Odpowiedź
+ 1
In the C programming language, static is used with global variables and functions to set their scope to the containing file. In local variables, static is used to store the variable in the statically allocated memory instead of the automatically allocated memory.
https://stackoverflow.com/questions/572547/what-does-static-mean-in-c#:~:text=In%20the%20C%20programming%20language,of%20the%20automatically%20allocated%20memory.
if a variable has no initial value it by default 0(zero) . And when that variables increment 0 becomes 1 and print 1 as well.
👉 let's have a look the code below quickly
https://code.sololearn.com/cab2MNAJh7F6/?ref=app