What does this statement mean?
//allocated memory for Device info
(*PppsCoreStructure)->psDeviceDetails=(sDeviceDetails **)calloc(CORE_DEVICEINFO_SIZE, sizeof(sDeviceDetails*));
I know that ‘(*PppsCoreStructure)->psDeviceDetails’ is a pointer to pointer. But I am not being able to imagine how calloc can return pointer to pointer? I’m a beginner please help
(*PppsCoreStructure)->psDeviceDetailsis declared with typesDeviceDetails **calloc()is of typevoid*(sDeviceDetails **)calloc(...)casts the return value ofcallocto be of typesDeviceDetails **In the C++ language this type cast is essential, although in C++ one would normally not be using
callocand would probably be using C++ casts.In the C language the type cast is not needed because a
void*pointer is assignment compatible with all other pointer types.In a comment you state
and I suspect that this is in fact your real question.
The answer is simple enough:
T*is a pointer-to-T andT**is a pointer-to-pointer-to-T.