I populated a structure(ORDER_EXPIRY_TP *OrderReqXml) and now I want to check whether structure conatains any value or not? Here is my code:
OrderReqXml->fIntOrderNumbe =at_int_ord_req->fIntOrderNumber;
OrderReqXml->dLocationCode = 0;
OrderReqXml->dQzUser = at_int_ord_req->dUserId
OrderReqXml->dSuperUserId = 0;
So basically i want 2 check whether OrderReqXml is null or not.
Really depends on what you are trying to achieve.
If you allocate your struct like this:
then, you should indeed check for the pointer being != NULL before assigning values to your struct. A good way would be:
If you obtain the pointer from somewhere else, e.g. from a static structure in memory and you want to check whether the struct has been populated or not, you need to check the single struct elements:
The question then is however, if you wanted to trust this struct in memory to be initialized with zeros. (You must not trust memory allocated with malloc() to be initialized to zero.)