Thread: allocating a single array

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    380

    allocating a single array

    would these two lines of code end up with the same results?

    int * ptr
    ptr = (int*)malloc(20 * sizeof(int));

    ptr = (int*)malloc(sizeof(int[20]));

  2. #2
    The Artful Lurker Deckard's Avatar
    Join Date
    Jan 2002
    Posts
    633
    Yes sir, they would.
    Jason Deckard

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to insert a single value into every array alement?
    By philvaira in forum C++ Programming
    Replies: 11
    Last Post: 08-10-2008, 02:05 PM
  2. Modify an single passed array element
    By swgh in forum C Programming
    Replies: 3
    Last Post: 08-04-2007, 08:58 AM
  3. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  4. Type and nontype parameters w/overloading
    By Mr_LJ in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2004, 01:01 AM
  5. Useing a single dimension array as a multi simension one
    By Eber Kain in forum C++ Programming
    Replies: 1
    Last Post: 02-16-2002, 06:25 PM