1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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,012
    Likes Received:
    203
    Trophy Points:
    0
    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