Thread: Realloc help

  1. #1
    Novice C++ Programmer
    Join Date
    Nov 2003
    Posts
    96

    Realloc help

    Ok I'm on the last page of my book and theres one small little problem I have been stuck on for about 20 minutes. I typed the code exactly how it says and in part of the code it does this:

    Code:
    int *arr;
    
    arr = calloc(5, sizeof(int));
    
    
    /* some code here...... etc... */
    
    
    /* then it gets to this */
    
    arr = realloc(8, sizeof(int));
    That last line is causing a compiler error that states:
    Warning: passing arg 1 of 'realloc' makes pointer from integer without a cast
    Yes, my program includes the proper <stdlib.h> library. No, I did not change the arr pointer type since the beginning. I don't quite understand how to fix this and what it is saying. Assistance would be appreciated. Thanks.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> arr = realloc(8, sizeof(int));

    It that's what's in your book, it's a misprint.

    realloc()

    gg

  3. #3
    Novice C++ Programmer
    Join Date
    Nov 2003
    Posts
    96
    Thanks. I see the book had an 8 where the pointer name that is being edited is supposed to go. Fixed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. did i understood right this explantion of realloc..
    By transgalactic2 in forum C Programming
    Replies: 3
    Last Post: 10-24-2008, 07:26 AM
  2. writing a pack-style function, any advices?
    By isaac_s in forum C Programming
    Replies: 10
    Last Post: 07-08-2006, 08:09 PM
  3. using realloc
    By bobthebullet990 in forum C Programming
    Replies: 14
    Last Post: 12-06-2005, 05:00 PM
  4. segfault on realloc
    By ziel in forum C Programming
    Replies: 5
    Last Post: 03-16-2003, 04:40 PM
  5. Realloc inappropriate for aligned blocks - Alternatives?
    By zeckensack in forum C Programming
    Replies: 2
    Last Post: 03-20-2002, 02:10 PM