Malloc & Calloc difference in terms of memory allocated

This is a discussion on Malloc & Calloc difference in terms of memory allocated within the C Programming forums, part of the General Programming Boards category; Hi People, Please find my queries mention below. -------------------------------------------------------------------------------------------------------- How is memory allocated by malloc? Is the memory allocated contiguous? ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    3

    Malloc & Calloc difference in terms of memory allocated

    Hi People,
    Please find my queries mention below.
    --------------------------------------------------------------------------------------------------------
    How is memory allocated by malloc?
    Is the memory allocated contiguous? Is so, What if the requested number of bytes are not available contigously?
    Is casting really required?? If u don't cast the pointer what will be the disadvantage?
    What is the difference between calloc and malloc in terms of memory allocation?
    --------------------------------------------------------------------------------------------------------
    I will be happy if some body could give me a diagramatic representation of the memory allocated by these two functions(calloc & malloc).

    Regards
    Swapna

  2. #2
    Lean Mean Coding Machine KONI's Avatar
    Join Date
    Mar 2007
    Location
    Luxembourg, Europe
    Posts
    444
    If you give me the email address of your teacher, I'll save you the work and mail him the answers directly, ok? First, here's our Homework Policy, read it and then ask specific questions while trying to give the answer yourself. You didn't even take the time to formulate the questions yourself, you're simply copied the assignment .. how lazy is that ?

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,659
    > Hai ue yqyadk mxxaomfqp nk ymxxao?
    Mmsuo yaefxk.
    Fmuxuzs ftmf, uf fkbuomxxk mewe ftq OS rad m nus nxaow ar yqyadk (eqhqdmx MB emk), ftqz otabe ftmf gb uzfa eymxxqd myagzfe fa ymfot mofgmx ymxxao omxx
    e.

    > Ie ftq yqyadk mxxaomfqp oazfusgage?
    Aximke.

    > Ie ea, Wtmf ur ftq dqcgqefqp zgynqd ar nkfqe mdq zaf mhmuxmnxq oazfusagexk?
    Yag sqf NULL nmow.

    > Ie omefuzs dqmxxk dqcgudqp??
    Na - eqq ftq FAQ

    > Ir g paz'f omef ftq bauzfqd itmf iuxx nq ftq puemphmzfmsq?
    Wqxx ur kag oagzf tupuzs qddade m puemphmzfmsq, omefuzs omz tupq ftqeq bdanxqye
    - rmuxgdq fa uzoxgpq efpxun.t
    - mffqybfuzs fa oaybuxq m C bdasdmy iuft m C++ oaybuxqd.

    > Wtmf ue ftq purrqdqzoq nqfiqqz omxxao mzp ymxxao uz fqdye ar yqyadk mxxaomfuaz?
    Nazq mf mxx.
    Last edited by Salem; 04-19-2007 at 12:59 AM. Reason: Following KONI's correct post about homework
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Will free() clean up this allocated memory?
    By simguy in forum C Programming
    Replies: 3
    Last Post: 01-18-2007, 04:21 PM
  2. Arrays and pointers to allocated memory
    By TriKri in forum C Programming
    Replies: 19
    Last Post: 07-23-2006, 10:52 AM
  3. Where are pointers allocated in memory?
    By sparks in forum C++ Programming
    Replies: 5
    Last Post: 07-20-2005, 12:52 PM
  4. calloc vs malloc
    By Jubba in forum C Programming
    Replies: 2
    Last Post: 02-21-2002, 03:54 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21