|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
I've just heard of this, and I know it has something to do with pointers (but I don't even know what pointers do yet). I know arrays also have positions, and I'm guessing pointers "point" to arrays in different positions, but I am really unsure.
|
| Sponsored Links |
|
|
|
|||||
|
An array is a variable that stores multiple pieces of data of the same type. This corresponds to the idea that an apartment building can store more than one family at the same address. Since each family needs to get their own mail, they are referenced by apartment number. Arrays use a similar technique to access their members.
Code:
int main()
{
int MyArray[5]=( 1, 3, 5, 7, 9 );
return MyArray[0];
}
MyArray[0] == 1 MyArray[1] == 3 MyArray[2] == 5 MyArray[3] == 7 MyArray[4] == 9 The name MyArray can be used as a pointer that points to MyArray[0]
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
|
|||||
|
Dang! I didn't even know we could get rep. I wouldn't have noticed if you didn't mention it, Crane.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
|
|||
|
Quote:
Code:
int MyArray[5] if an array is used incorrectly, you will read memory outside the bounds of the array, for example, if I try to find the value of MyArray[9] , it will give me a value, it will just turn whatever junk is stored in those 32 bits in memory into an int. You can also access memory in front of the array as well, for example: MyArray[-1] will return the value 32 bits before the first item.
__________________
<!-- comment comment comment --></ Last edited by kromagnon; 07-26-2006 at 04:17 PM. |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Python arrays... | Sir_Rimo | Python | 3 | 06-20-2007 08:54 AM |
| variable length arrays in C | rattlepanos | C and C++ | 3 | 05-03-2007 11:35 AM |
| Arrays | clookid | PHP Tutorials | 1 | 01-11-2007 08:30 PM |
| Are arrays sort of like matrices? | Sionofdarkness | Java Help | 5 | 08-21-2006 02:30 PM |
| Arrays in NET 2.0 or CLI Managed C++ | Void | Managed C++ | 1 | 07-18-2006 07:57 PM |
| Xav | ........ | 1357.94 |
| MeTh0Dz|Reb0rn | ........ | 1083.85 |
| WingedPanther | ........ | 919.18 |
| morefood2001 | ........ | 909.18 |
| marwex89 | ........ | 906.86 |
| John | ........ | 902.37 |
| Brandon W | ........ | 789.89 |
| chili5 | ........ | 312.39 |
| Steve.L | ........ | 264.99 |
| dcs | ........ | 240.34 |
Goal: 100,000 Posts
Complete: 83%