cheking whether memory has allocated dynamically or not ?

Discussion in 'C' started by karthik.v, Oct 18, 2010.

  1. karthik.v

    karthik.v New Member

    Joined:
    Oct 18, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hi...

    please tell me how to check whether memory has allocated dynamically or not ?


    any help is greatly appreciated.

    thanks in advance :)
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    If malloc returns NULL, then it didn't allocate anything.
     
  3. zaster

    zaster New Member

    Joined:
    Oct 9, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    If you are using C++, new throws bad_alloc exception if memory is not allocated.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice