hi
please help me with the concept of pointer to an array and also macros.
regards
Mrunal
hi
please help me with the concept of pointer to an array and also macros.
regards
Mrunal
i am not an expert...but i KNOW that when we tell "there is apointer to an array we mean a pointer to the first element of the array, the first cell if you want".
for example: if we have an array of integers size 10.
and a pointer: *ptrCode:int A[10];
this part:Code:int *ptr;simply "strores" to the pointer the beginning of the array. the A[0] cell.Code:ptr = &A[10]
However what i told you is somehow general can you be more specific to what do you want to do?
If you are having array A of size 10, you can access from A[0] to A[9], a[10] will be a garbage.
here ptr will store address of A[10] cell, i.e. of 11th cell which will be having garbage.Code:ptr = &A[10];
there are two ways
1.2.Code:ptr=&A[0];As in 2nd case, name of array gives base address of array i.e. A[0]Code:ptr=A;
Thanks ,everyone .I did it,this is my solution
Code:void swapColumns(double a[][6],int row,int col,int fswap,int sswap) { int i; double hold,*px; px=a; for (i=0;i<row ;i++) { hold=*(px+i*col+fswap); *(px+i*col+fswap)=*(px+i*col+sswap); *(px+i*col+sswap)= hold; } }
Hi,
well,
there's some problem with your coding...
look this when i compile them >
http://i235.photobucket.com/albums/e.../untitled5.jpg
i don't think that px = a; is a valid command