Thread: How to allocate memory for array of pointers using "new"?

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    88

    How to allocate memory for array of pointers using "new"?

    I want to make an array of pointers to (int) using "new".

    int * a = new ???? ; // (int *) (99) ; ???


    thx

    /* If you think my question is unclear, please tell me. I am not an English speaker. */

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    int *a points to an array of integers, not an array of pointers to integers.

    To allocate an array of pointers to integers:
    int ** a = new int*[size];
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    88
    I got it. thx.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems with shared memory shmdt() shmctl()
    By Jcarroll in forum C Programming
    Replies: 1
    Last Post: 03-17-2009, 10:48 PM
  2. Memory allocation/reallocation
    By magda3227 in forum C Programming
    Replies: 10
    Last Post: 07-04-2008, 03:27 PM
  3. To find the memory leaks without using any tools
    By asadullah in forum C Programming
    Replies: 2
    Last Post: 05-12-2008, 07:54 AM
  4. dynamic memory allocation and returning pointers
    By sballew in forum C Programming
    Replies: 7
    Last Post: 11-03-2001, 03:21 PM
  5. How to allocate memory in multidimensional array?
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 10-15-2001, 10:07 AM