16 binary conversion to dotted decimal string (IP address form)

Source: Internet
Author: User
Include "Csapp.h" void main (int argc,char* argv[]) {char *hex=argv[1]; if (argc<2| | *hex!= ' 0 ' | |  * (hex+1)! = ' x ') printf ("Input error!you should input like this:%s 0x8002c2f2\n", argv[0]);  int dd[4];  int i;    for (i=1;i<=4;i++) {Char ch1 = * (hex+i*2);    Char CH2 = * (hex+i*2+1);    int dd1;    int dd2;    DD1 = Char2int (ch1,15);    DD2 = Char2int (ch2,16);  Dd[i-1] = DD1*16+DD2; } printf ("Dotted decimal form: \t%d.%d.%d.%d\n", dd[0],dd[1],dd[2],dd[3]);}


16 binary conversion to dotted decimal string (IP address form)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.