#malloc issue

28 messages · Page 1 of 1 (latest)

rancid parrotBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

polar dagger
#

can't call a function outside a function

#

IOW, in global scope what one can do is very limited, and malloc(...) call isn2t allowed

#

this is my guess as to what's happenning without the light of a proper error message, sorry

solar oasis
#

why are we doing typedef struct Node* NodePtr;?

#

Node* nodePtr = malloc(...)

#

but it's not a struct, is it?

#

it has no data

#

why would it be a struct?

#

no.

#

is it a struct? does it contain data?

#

riiight

polar dagger
#

if you can share the error message, i can guess something else because it works with the information you provided

#

typedef is valid C code even though questionable practice

#

questionable because it hides the type is a Pointer

#

even though the name literally has Ptr

#

you need to include a header

#

that has the declaration of the function malloc

#

which is the stdlib header

#

don't get me wrong but if you shared this warning in the original post, we would have spared a waste of time from both ends

#

you and people here

#

the compiler is being soft and proceeds to compile anyway

#

it's a "warning" as it says, not a fatal error

#

but that's not to be relied on at all

#

np

proven kraken
#

I wish the C compiler would not assume "a function returning an int".
Just error out and force me to fix my stupid mistake.
Otherwise I am just chasing my tail.

rancid parrotBOT
#

@surreal crystal Has your question been resolved? If so, type !solved :)

#

@surreal crystal

Please Do Not Delete Posts!

Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.