#p1 a logical condition?

22 messages · Page 1 of 1 (latest)

azure prawn
#

what is p1 ?

covert urchinBOT
#

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.

#

@azure prawn

Screenshots!

Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!

wraith sparrow
#

No you dont, C does implicit type conversions

#

p1 is just a pointer to the first element in the array.
*(p1+1) would be the second and so on.
*(p1+1) is the same as doing p1[1]
hope this helps

narrow sinew
#

i wouldn't call it array. p1 is a pointer to some block of memory.
arrays as types are different

livid forum
#

ty

wraith sparrow
azure prawn
#

its the example from ccpreference

wraith sparrow
#

void* can be converted to any pointer type.

narrow sinew
azure prawn
soft lintel
#

if (x) means if (x != 0)

azure prawn
#

how is this tree entered ? i dont get the condition

steel hill
#

in case of pointers, it checks if the pointer is not a null pointer

narrow sinew
#

if(p1) is the same as if(p1 != NULL)

wraith sparrow
#

yea

steel hill
#

malloc returns a null pointer on failure, so it checks instead of directly using it

#

after all, the (m)allocation could have failed