|
-
Dec 8th, 2002, 11:04 PM
#1
Thread Starter
Frenzied Member
Declare Public Variables in C
How do I declare a public array or other variables using C?
I need to know syntax and placement of code...
thanx,
Squirrelly1
Now happily married and still crankin' away at the keyboard.  Life is grand for a coder, no?
-
Dec 9th, 2002, 08:01 AM
#2
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...
Last edited by CornedBee; Dec 9th, 2002 at 08:19 AM.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 9th, 2002, 10:21 AM
#3
Frenzied Member
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;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|