Understanding multidimensional arrays in c++

Discussion in 'Programming' started by chesss, Jun 14, 2009.

Thread Status:
Not open for further replies.
  1. chesss

    chesss mera kutch nahi ho sakta

    Joined:
    Oct 22, 2005
    Messages:
    876
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    Delhi
    Heres a simple multi array - char c[10][10] = {"sunday", "monday"};

    now my question is, in this case what will be c[0] or c[1] ? and what are their types ?

    Please think and answer.
     
  2. krishnandu.sarkar

    krishnandu.sarkar Simply a DIGITian

    Joined:
    Nov 13, 2007
    Messages:
    4,693
    Likes Received:
    15
    Trophy Points:
    38
    Location:
    Kolkata
    As far i knw multi-D arrays can't b accessed in a single-D array......
    But as ths is a char array it may b 's' in c[0]

    correct me if i'm wrong...!!
     
  3. OP
    OP
    chesss

    chesss mera kutch nahi ho sakta

    Joined:
    Oct 22, 2005
    Messages:
    876
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    Delhi
    well I can't be sure, but I think that c[0] is the name/identifier of an array, since the name of an array c[0] allow acts like a pointer, it stores the address of of the first element c[0][0].
     
  4. Liverpool_fan

    Liverpool_fan Sami Hyypiä, LFC legend

    Joined:
    Jun 19, 2007
    Messages:
    2,209
    Likes Received:
    26
    Trophy Points:
    0
    Location:
    Нью-Дели
    c[0] -> "sunday"
    c[1] -> "monday"

    c[0][0] -> 's' and so so
    c[1][0] -> 'm' and so on
     
  5. cool.aquarian

    cool.aquarian New Member

    Joined:
    Mar 28, 2007
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    India
    thats right...
    was this so difficult?
     
  6. adatapost

    adatapost New Member

    Joined:
    Jul 5, 2009
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    India/Gujarat/Mehsana
    char pointer.
     
Thread Status:
Not open for further replies.

Share This Page