Pointers and Arrays in C/C++ -


People I'm trying to bring down some theoretical stuff for pointers and arrays. I was hoping someone could confirm some suspicions with the concept of signs and arrays.

Suppose I had something like this

  int ia [] = {0,1, 2,3,4,5}; Come [2]; // = 2 int * ip = & amp; Iia [0]; // Pointer IP array gets the address of element 0 in IIP IP [2]; // ?? IP [2] = 42; //   

Most of this code is clearly theoretical but there is little uncertain about the previous 2 lines. Firstly the IP is saying [2] similar to the IP saying the second in the array Element indicates? Is it equal to say * ip = ia [2]?

Im also confused with the last line [2] = 42; So the second element of the object, which points to the IP, gives that value to 42? Or is it that dereferencing an array signaling method? Im just a little confused on whats going on

The following IA creates an array and in the curly braces in the number store array:

  int ia [] = {0,1,2,3,4,5};   

In the following effect, nothing does:

  ia [2];   

However, if I take the above details and make the changes as follows, then it assigns the value of T to the integer T. 2. The reason for this is that 2 is the third element in IA, and IIA refers to the third element in the IIA. [2]

  T = IIA [2];   

If your IIAA's original announcement was made

  int ia [] = {0,1,15,3,4,5};   

Then you specify T to 15.

The value of the index returns to 2 of the following:

  IP [2] = 42;   

Now, there are {0,1,42,3,4,5} in the IIA.

The reason for this is that IA [2] is like saying * (I + 2). If you give the IIS to the IIC, then the IP points to the first element of the IIA.

Similarly, the IP [2] is saying as (IP + 2). Therefore, changing the IP [2] will replace the IIA [2], they refer to the same part of memory.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -