Thread: Malloc warning

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    151

    Post Malloc warning

    I am getting an implicit declaration warning of the malloc function. What is wrong here.


    Code:
    void StackInit(stackST *stackP)
    {
      stackElement *newContents;
    
      /* Allocate a new array to hold the contents. */
    
      newContents = (stackElement *)malloc(sizeof(stackElement) * 10);
    
      stackP->contents = newContents;
      stackP->lineST = 0;
      stackP->top = -1;  /* I.e., empty */
    }
    Please reply.

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Stop casting malloc and #include stdlib.h to get the proper prototype.

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    151
    Thanks, thats fixed it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 07-10-2008, 03:45 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM