i'm new to programming. I wanted to create two integer arrays which are adjacent in memory. i had written the following code, but i'm getting segmentation fault when i run it.

Code:
#include<iostream>
using namespace std;

void printarray(int* a,int size)
{
        for(int i=0;i<size;i++)
        cout<<a[i]<<endl;
}

int main()
{
        int a[3]={0,1,2,}; //the first array
        int* pa;
        pa = &(a[2]);
        pa++;
         int* b = pa; //the second array


        for(int i=0;i<3;i++)
        {
                b[i]=i+2;
         }
        printarray(a,3);
        printarray(b,3);

}
any help would be greatly appreciated..thanks

Last edited by shabbir; 28Jul2008 at 14:51.. Reason: Code block