Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
C syntax
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====Array definition==== Arrays are used in C to represent structures of consecutive elements of the same type. The definition of a (fixed-size) array has the following syntax: <syntaxhighlight lang=C>int array[100];</syntaxhighlight> which defines an array named ''array'' to hold 100 values of the primitive type {{code|int}}. If declared within a function, the array dimension may also be a non-constant expression, in which case memory for the specified number of elements will be allocated. In most contexts in later use, a mention of the variable ''array'' is converted to a pointer to the first item in the array. The [[sizeof|{{code|sizeof}}]] operator is an exception: {{code|sizeof array}} yields the size of the entire array (that is, 100 times the size of an {{code|int}}, and {{code|sizeof(array) / sizeof(int)}} will return 100). Another exception is the & (address-of) operator, which yields a pointer to the entire array, for example <syntaxhighlight lang=C>int (*ptr_to_array)[100] = &array;</syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)