Arrays

This is a discussion on Arrays within the C Programming forums, part of the General Programming Boards category; Hello, I am pretty new to C and have a hard time understanding what an array is and what it ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    6

    Question Arrays

    Hello, I am pretty new to C and have a hard time understanding what an array is and what it is used for could someone help explain?

  2. #2
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,167

  3. #3
    Registered User
    Join Date
    Oct 2009
    Location
    While(1)
    Posts
    377
    Arrays are meant for storing similar data types at contiguous locations for you

    Lets take an example

    i am having an array which is like this

    Code:
    int array[3] = {1, 2, 3};
    then the memory location for the array will be like

    0xFF0000 value == 1
    0xFF0004 value == 2
    0xFF0008 value == 3

    And i am taking that int take 4 byte or a word in a memory
    And with array you can perform operations fast

    Think an example that you want to store marks of 50 students in a class..
    You will not declare 50 variables for each student then what you can do declare an array which can hold 50 student marks kind of so long story dude just google it or wiki it

  4. #4
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,167
    And with array you can perform operations fast
    Array has little to do with speed.

    It could be faster if they are in 3 variables stored in registers.

  5. #5
    Registered User
    Join Date
    Nov 2009
    Posts
    6
    i see, thx rocky. i did google it, reread the array section in the book i bought, and even asked my professor but i still did not understand

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by cyberfish View Post
    Array has little to do with speed.

    It could be faster if they are in 3 variables stored in registers.
    I believe he means 'speed' as 'convenience', not as 'performance'. It's easier to type:
    Code:
    int foo[ 50 ];
    than it is to type:
    Code:
    int foo1;
    int foo2;
    ...
    int foo50;

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to create and manipulate Terabyte size Arrays with Win32API
    By KrishnaPG in forum Windows Programming
    Replies: 1
    Last Post: 11-05-2009, 03:08 AM
  2. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 03:24 PM
  3. Replies: 16
    Last Post: 01-01-2008, 03:07 PM
  4. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 09:47 PM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 08:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21