Hello,

I am new to this site and the program language of C.

I am trying to create a program that would allow me to convert 32 bit binary (in chunks of 8 bits) ip to decimal ip. Also, I am trying to convert from decimal ip to 32 bit binary ip.

I am totally lost to convert 32 bit binary to decimal ip but I think I have an understanding of converting decimal ip to 32 bit binary ip.

Any help would be greatly appreciated.

Here is the code I have so far for decimal IP to Binary IP (Am I missing anything?)
Code:
{
// Initialize the variables
unsigned long a,b,c,d,base10IP;

// Get the IP address from user
cout << "\nEnter an IP address in dotted quad notation (x.x.x.x)";
cout << "\nwith each section seperated by a space: ";
cin >> a >> b >> c >> d;

// Do calculations to covert IP to base 10
a *= 16777216;
b *= 65536;
c *= 256;
base10IP = a + b + c + d;

// Output new IP address
cout << "\nThe converted address is: " << base10IP << '\n';
}