While using socket library of c++, I find the following pointer (servinfo) to the library function getaddrinfo. Now I need to know the array size of the pointer servinfo (allocated by the library function) so that I can access each element of the array. How can I get the size of the array servinfo.

struct addrinfo *servinfo;

getaddrinfo(NULL, "3490", &hints,
	&servinfo)) != 0

Thanks.

Here is a quick poor man's method:

int elements = sizeof(serviceinfo) / sizeof(serviceinfo[0]);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.