#include <iostream.h>
main()
{
// 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';
}
this is the following code which i could manage to figure out, please help me to convert this from decimal to hexa also if possible please send me a C++ program to convert hexadecimal notation to decimal notation
IP ADDRESSProgram in C++ to convert 32 bit ip address from decimal notation to h
Page 1 of 1
1 Replies - 5404 Views - Last Post: 26 March 2008 - 11:01 PM
Replies To: IP ADDRESS
#2
Re: IP ADDRESS
Posted 26 March 2008 - 11:01 PM
...2nd result on Google searching "convert decimal to hex".
No one is going to give you a program. We will do our best to help you out, & answer questions, but we don't give out programs here, sorry.
int main() {
char outStr[256];
int inDec = 65535;
sprintf(outStr,"%x",inDec);
printf("%d in hex is %s\n",inDec,outStr);
}
Quote
also if possible please send me a C++ program
No one is going to give you a program. We will do our best to help you out, & answer questions, but we don't give out programs here, sorry.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|