What are static and…
 
Notifications
Clear all

What are static and global variables ?

1 Posts
2 Users
0 Likes
576 Views
0
Topic starter

are they the same ? elaborate please.

1 Answer
0

 Global variables: Variables declared as static at the top level of a source file (outside any function definitions) are only visible throughout that file.

 

Static local variables: Variables declared as static inside a function are statically allocated, thereby keeping their memory cell throughout all program execution, while also having the same scope of visibility as automatic local variables. Hence whatever values the function puts into its static local variables during one call will remain the same whenever the function is called again.

 

Share: