Pointers to arrays

This is a discussion on Pointers to arrays within the C Programming forums, part of the General Programming Boards category; Code: int main() { int *p; int (*q)[5]; int a[]={1,2,3,4,5}; int b[]={6,7,8,9,10}; p = a; q = b; ............. ............. ...

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    53

    Pointers to arrays

    Code:
    int main()
    {
         int *p;
         int (*q)[5];
         int a[]={1,2,3,4,5};
         int b[]={6,7,8,9,10};
         p = a;
         q = b;
         .............
         .............
    }
    In the above program, p is a pointer to an integer while q is a pointer to an array of 5 integers. Bothe p an q pointers same in their purpos?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,717
    "Bothe" is an amusing contraction for "both the"

    Anyway, my answer would be no. Think about what you would use them for.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with arrays, pointers, and structs.
    By RexInTheCity in forum C Programming
    Replies: 5
    Last Post: 03-29-2010, 03:30 PM
  2. Pointers As 2D arrays
    By TieFighter in forum C Programming
    Replies: 29
    Last Post: 03-22-2010, 06:46 AM
  3. pointers to arrays
    By rakeshkool27 in forum C Programming
    Replies: 1
    Last Post: 01-24-2010, 06:28 AM
  4. Array of Pointers to Arrays
    By Biozero in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 02:31 PM
  5. Pointers and multi dimensional arrays
    By andrea72 in forum C++ Programming
    Replies: 5
    Last Post: 01-23-2007, 03:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21