1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

program for accessing a array using pointer

Discussion in 'C' started by bashamsc, Dec 18, 2007.

  1. bashamsc

    bashamsc New Member

    Joined:
    May 22, 2007
    Messages:
    51
    Likes Received:
    7
    Trophy Points:
    0
    Location:
    chennai
    Code:
    #include<iostream.h>
    main()
    {
    int* a;int arr[2][3];
    
    arr[0][0]=1;
    arr[0][1]=2;
    arr[0][2]=3;
    arr[1][0]=4;
    arr[1][1]=5;
    arr[1][2]=6;
    
    a = &arr[0][0];
    
    
    int i,j;
    
    for(i=0;i<2;i++)
    {
    for(j=0;j<3;j++)
    {
    cout<<*(a+j)<<endl;
    }
    a=a+3;
    }
    }
    
    
     
    Last edited by a moderator: Dec 18, 2007
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,287
    Likes Received:
    364
    Trophy Points:
    83
    Instead of using the color block around the code use the code block.
     
  3. Salem

    Salem New Member

    Joined:
    Nov 15, 2007
    Messages:
    133
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Please don't PM me for 1:1 support.
    Was there a question in there?
    It's just code, no explanation, no questions, nothing, nada, zip, zilch.
     

Share This Page