How to get category of current post

Following code can be used to get the category of the current post which you are dealing with

You can use the get_the_category( $post->ID ) to get the category. What you have pass here is the ID of the post. You can get the ID of the post using the $post global variable

Use print_r($postcat) to see what is coming with category object