Thread: Arrays with pointers

  1. #16
    Registered User
    Join Date
    Aug 2009
    Posts
    140
    In the integer example, the name "intarr" is the address of the first element, which is the array (1,2). This address is equivalent of the address of 1. Now, why is it that it still does not work?

    Because of types (I think that it what you meant). But what are the different things in post 12/13?

  2. #17
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Niels_M View Post
    Ok, I feel like this thread got de-railed totally. I really appreciate all the input so far, but it does not seem to be answers to my OP.

    I still don't feel like I have gotten a clear answer, so if anybody would help, I would appreciate it very much.
    They're still discussing your original issue.
    I am not 100% sure of what the standard says, but so far as I see, there is simply no implicit conversion from int[][] to int*[].
    I believe that the 1D array is simply a special case as it decays to a mere pointer. In the 2D case, it treats the right-hand side as an array (which does not decay).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #18
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    A: The rule (see question 6.3) by which arrays decay into pointers is not applied recursively. (Once the rule has been applied once, the result is a pointer to which the rule no longer applies.) An array of arrays (i.e. a two-dimensional array in C) decays into a pointer to an array, not a pointer to a pointer. Pointers to arrays can be confusing, and must be treated carefully; see also question 6.13.
    c-faq

  4. #19
    Registered User
    Join Date
    Aug 2009
    Posts
    140
    Just so I can understand fully what the C-FAQ is telling me, I will restate Bayint Naung's question he posed me:

    What is the difference between the following?

    intarr + 1
    &intarr[0] + 1
    &intarr[0][0] + 2

    I know the last is the address of the element '3' in the 2D-array intarr[2][2]=((1,2), (3,4)) (it should be curly brackets, I know..). But what are the two others?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with arrays, pointers, and structs.
    By RexInTheCity in forum C Programming
    Replies: 5
    Last Post: 03-29-2010, 03:30 PM
  2. Pointers As 2D arrays
    By TieFighter in forum C Programming
    Replies: 29
    Last Post: 03-22-2010, 06:46 AM
  3. pointers to arrays
    By rakeshkool27 in forum C Programming
    Replies: 1
    Last Post: 01-24-2010, 07:28 AM
  4. Array of Pointers to Arrays
    By Biozero in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 02:31 PM
  5. Pointers and multi dimensional arrays
    By andrea72 in forum C++ Programming
    Replies: 5
    Last Post: 01-23-2007, 04:49 PM