How do I declare a public array or other variables using C?
I need to know syntax and placement of code...
thanx,
Squirrelly1
Printable View
How do I declare a public array or other variables using C?
I need to know syntax and placement of code...
thanx,
Squirrelly1
No such things as access specifiers in C. Just declare a global variable somewhere (not inside a function).
syntax of variable declarations:
storage-class-specifier type-specifier variables;
storage-class-specifier: static | extern | volatile | register | auto
type-specifier: [const] (default types | structs | unions | typedefs)
variables: variable{, variable...}
variable: [* [const]] identifier[\[size\]][= initialValue]
initialValue: literal
identifier: /[A-Za-z_][A-Za-z0-9_]*/
size: constant positive integer
Did I miss something? I made it up myself, it's not copied or anything...
An example:
Code:#include <stdio.h>
int global_value=1; // outside of any function or in the header file
int main(){
int local_value; // inside a function
local_value=2;
printf("local_value: %d global_value: %d\n",
local_value, global_value);
return 0;
}