how to convert ipaddress/mask to CIDR using c++?

Viewed 9053

I have a list of ipaddress/mask which needs to be converted to CIDR notation.

for e.g. 12.174.36.240/24 needs to be converted to 12.174.36.0/24 or something like what http://www.subnet-calculator.com/cidr.php does

How can this be acheived?

PS: the mask value is not always 24.

2 Answers
Related