Question:
C programming,very short question?
Jason
2013-04-02 21:48:35 UTC
Here is the link for my program and sample run

It compiles will following warnings:

https://www.dropbox.com/sh/a7yrhhr45tdto55/rcrDOpj7xd

Bag.c: In function âempty_bagâ:
Bag.c:73: warning: incompatible implicit declaration of built-in function âmallocâ câ

However when I run it, it words perfectly fine,and I do't know what and why it complaining?

if there are other error or mistakes ,please let me know .

Thanks a lot
Three answers:
James
2013-04-02 21:53:44 UTC
The malloc() function is undeclared so in C using an undeclared function is an "implicit declaration." The implicit declaration return type is int, and this does not match the built in definition that gcc uses.



To solve it include the stdlib.h header at the beginning of your program.

#include
2013-04-02 21:58:08 UTC
This isn't an error, it's a warning that the malloc() function which is a built-in function has not been defined. The compiler thinks you are making a function overwriting the built-in function malloc() because you never included the library, since it never found a explicit decoration of it it assumes you are using the built-in function. That's why it will still work. To fix this add:



#include



To the top of your file with the rest of your libraries.
fieger
2016-10-25 14:41:52 UTC
Your call sounds like an sufficient summery of my existence or existence. jointly with an encyclopedia article or professional from 'The Hitchhikers handbook to the Galaxy' :p the inner rhyme on L6 is really cool - Pun on inner you want a distinct and extra compelling topic LC. something to placed each and every of the coronary heart into, The second very last line is really unique in the way you clarify this sense. A heritage which overwhelms. i am going to go away it there. heavily locate a clean topic :( i do not opt to sound like some pretentious reader yet for you on a own element, this is better to write down about something which uplifts the author. something you create may have your expertise interior it, yet craft is secondary at the same time as the problem or problem is the priority :( I see you reminiscent of Shalott at the moment, in probability of lack of life from shadow poisoning or cracking up your mirror. <3 i like you and do not opt to ascertain piece of your discomfort.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...