Thread: malloc, realloc..wat on earth!

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    16

    Unhappy malloc, realloc..wat on earth!

    hey guys..i need some help on understanding how to use malloc and then realloc in my programme..the sizes of my arrays are always varying based on some parameters that i have in my program, so i know that i need to use the realloc function for the sizes of several arrays, but to do that i must first use malloc which i have no idea how to use!..so help pleasee..i need to use it for the sizes of these arrays, all of type float: t[i], x[i].
    i know it has something to do with declaring pointers, but i dnt no which pointers to declare!


    many thanxxxxxxxxxx

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    There are some examples in the FAQ.
    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.

  4. #4
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    here is one good tutorial for you http://randu.org/tutorials/c/dynamic.html

    ssharish

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. malloc and realloc
    By jayfriend in forum C Programming
    Replies: 4
    Last Post: 01-05-2007, 02:25 PM
  2. To malloc or not realloc on struct members
    By gh0st in forum C Programming
    Replies: 4
    Last Post: 11-17-2006, 05:27 AM
  3. malloc, realloc
    By figo2476 in forum C Programming
    Replies: 3
    Last Post: 04-28-2006, 10:11 PM
  4. malloc and realloc
    By odysseus.lost in forum C Programming
    Replies: 3
    Last Post: 05-27-2005, 08:44 AM
  5. Need help on malloc and realloc
    By YevGenius in forum C Programming
    Replies: 8
    Last Post: 03-06-2004, 01:55 AM