Thread: What are arrays?

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    18

    What are arrays?

    Can someone explain to me what arrays are? So I can understand them? thank you.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    An array is a fixed size collection of objects (aka elements). They can be any type that C supports, such as char, int, struct, union, pointers, double, float.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059

  4. #4
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    An array is a number of something. For example, a char array would be a number of datatype char. They are convienently numbered in order and referred to with one name. This allows you to work with strings, like "this is a string", because "this is a string" contains 15 characters.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  5. #5
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Quote Originally Posted by MK27 View Post
    An array is a number of something. For example, a char array would be a number of datatype char. They are convienently numbered in order and referred to with one name. This allows you to work with strings, like "this is a string", because "this is a string" contains 15 characters.
    That is a little more cryptic than a definition need be. An array is more like a super block of data that is built out of smaller units chained together.

  6. #6
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    and for an impromptu definition..."a logically contiguous row of memory locations used for storing data"

  7. #7
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I like that definition.

    A bunch of something... int array[45] means you have a list of 45 ints. array[0] would be the first and array[n-1] would be the last. Since in this case n = 45, n-1= 44. so array[44] is the last index of the array.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function to read in two arrays
    By ssmokincamaro in forum C Programming
    Replies: 7
    Last Post: 11-12-2008, 07:59 AM
  2. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 04:24 PM
  3. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  4. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 10:47 PM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 09:24 PM