[ create a new paste ] login | about

Link: http://codepad.org/Vdeipufk    [ raw code | output | fork ]

C++, pasted on Nov 14:
#include <iostream>

using namespace std;

int main()
{
    int a[2][3] = {1,2,3,4,5,6};

    for(int i=0; i<2; ++i)
    {
        for(int j=0; j<3; ++j)
        {
            cout<<a[i][j]<<"\t";
        }
        cout<<endl;
    }
    cout<<endl;

    int (*ptr)[3]=a;

for(int i=0; i<6; ++i)
    {
        for(int j=0; j<6-i; ++j)
        {
            cout<<(*ptr+i)[j]<<"\t";
        }
        cout<<endl;
    }
    cout<<endl;

    for(int i=0; i<2; ++i)
    {
        for(int j=0; j<3; ++j)
        {
            cout<<ptr[i][j]<<"\t";
        }
        cout<<endl;
    }

    return 0;
}


Output:
1
2
3
4
cc1plus: warnings being treated as errors
In function 'int main()':
Line 7: warning: missing braces around initializer for 'int [3]'
Line 7: warning: missing braces around initializer for 'int [3]'


Create a new paste based on this one


Comments: