Thread: Correct usage of malloc()

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Tropical Coder Darryl's Avatar
    Join Date
    Mar 2005
    Location
    Cayman Islands
    Posts
    503
    malloc returns void*, so you will have to cast. Since you posted this is the c++ forum and not the c forum, I am curious to why you aren't using new instead?

    int* data = new int[10];
    Last edited by Darryl; 07-24-2005 at 04:57 AM.

  2. #2
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    I was just wondering really. Is malloc() considered standard C++?
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Random number + guessing game trouble
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-08-2007, 03:33 AM
  2. Is there a limit on the number of malloc calls ?
    By krissy in forum Windows Programming
    Replies: 3
    Last Post: 03-19-2006, 12:26 PM
  3. quick malloc question
    By thedoofus in forum C Programming
    Replies: 2
    Last Post: 10-15-2005, 05:41 AM
  4. Simple Question on Correct Usage of memset
    By deadpoet in forum C++ Programming
    Replies: 2
    Last Post: 03-16-2004, 08:58 AM