Thread: Using calloc

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2007
    Location
    Giessen, Germany
    Posts
    2
    <<mod edit - split from thread >>

    Hi there,
    i am also new to c programming and have also a question concerning the malloc/free functions.
    The following code:
    Code:
    double *pAr = (double*)calloc(100, sizeof(*pAr));
    for(i=0;i<101;i++)
           do something
    
    if(pAr)free(pAr);
    The program gives a segmentation fault when calling "free"
    where I would expected to do so when passing over the array boundary
    or to ignore that.
    Last edited by Salem; 11-07-2007 at 09:43 AM. Reason: Split thread

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. malloc, calloc from the FAQ
    By salvadoravi in forum C Programming
    Replies: 10
    Last Post: 01-21-2008, 03:29 AM
  2. Help with calloc and pointers to strings.
    By sweetarg in forum C Programming
    Replies: 1
    Last Post: 10-24-2005, 02:28 PM
  3. Malloc and calloc problem!!
    By xxhimanshu in forum C Programming
    Replies: 19
    Last Post: 08-10-2005, 05:37 AM
  4. Why use calloc()?
    By dwks in forum C Programming
    Replies: 8
    Last Post: 07-20-2005, 08:22 AM
  5. difference between calloc and malloc
    By saravanan_ts in forum C Programming
    Replies: 4
    Last Post: 07-28-2003, 06:13 AM