i am clear with the concept of Array of pointers & pointer to an Array.

but i wonder what is the advantage of creating a pointer to an array
though the same can be done just by using twod array with row and col indexes.

please some let provide me some info and advantages of pointer to an array.


what is the the different between these below statements: printf("%c", ptr[0][1]); printf("%c",ptp[0][1]); they access the same value using same notation.

int main()
{
        char str[4][10]= {"Alex","Sue","Brev","Prin"};
        char (*ptr)[10] = str ;
        char *ptp[] = {"Alex","Sue","Brev","Prin"};
        printf("%c", ptr[0][1]);
        printf("%c",ptp[0][1]);
        return 0;
}

Thanks

line 5 takes up less memory than line 3. In line 3 each of the strings are allocated 10 bytes of memory, while in line 5 there is no memory reserved for the strings at all in the array.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.