[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –
C++ Programming Tutorial – 10 – Introduction to Arrays
by
Tags:
Comments
22 responses to “C++ Programming Tutorial – 10 – Introduction to Arrays”
-
I learned more from you then my professor, thx
-
Thanks for this tutorial! It really helped!
-
hey do you know how to print the least occured digit in an array like 1004, 2111,8?
-
' i like spelling things '
-
You start counting at zero because you are referencing a integer at the memory position of your bacon variable with a offset of: (index between brackets) * (size of array element). Using a index of 1 would result in a offset of 1 integer, so the first 32 bits would never be used.
Say the compiler has memory location #1000 free of resources and you assign the bacon variable with the line:
int bacon[5]={12,43,54,3,897};
Then the variable "Bacon" will get memory location #1000
If you then look in memory it will look like this:
Byte #1000 till #1003: "12"
Byte #1004 till #1007: "43"
Byte #1008 till #1011: "54"
Byte #1012 till #1015: "3"
Byte #1016 till #1019: "897"If you then want the first value, you will need position: 1000 + (index * sizeof(integer)) = 1000 + (0 * 4 bytes) = 1000
So, when using the line:
cout << bacon[2];
You are telling the program to cout 4 bytes (as a integer) starting from memory location: 1000 + 2 * 4 = 1008, which is the 3rd item.
-
hahaha =))) all i can say is that is damn fun to watch this tuts. :)))
-
why dont you do some tutorials for how to do games in dev c++
-
excellent work sire!! 🙂
-
Pretty good, I understood every word you said, even that I don't speak too much English xD
-
thanks, very helpful 🙂
-
thankzz
-
Good lord! ur voice sounds so Angelic.
-
Ok.. I'm using dev c++ and when I try to run this, I get a bunch of compiler errors unless I have using namespace std in the body of the main function. I thought once it's within the body of the program directly below include <iostream> that it was automatically included in every function. What am I doing wrong?
-
you're not boring as my teacher…Love your tutorials.. thanks for making these awesome tuts
-
Dude , u are awesome ! i can see where i make a mistake on my program as u were xplaining ! thanks a lot !
-
Thanks! You just broke it down for me! . "An array is a variable that holds multiple values" By the way , I love you and I am STRAIGHT!!! lol
-
you're awesome! :DDD
-
And they start with zero as to incorporate all possible digits. If it started at 1, 0 wouldn't be in that set.
-
Variable=Object Better to say an array is an object because it is C++. C++ is an object-oriented programming language. Array's are objects. Not really variables
-
Translation (not that it needed it): I don't understand this.
-
Because they don't browse YouTube.
-
if he really is, then, why doesn't he get an award from guinness?
Leave a Reply