(Original) how to capture the host ID of the C class IP address? (C/C ++) (c)

Source: Internet
Author: User

Abstract
My classmates asked me a little question. If it's still interesting, I just want to read it.

Introduction
Use environment: Visual C ++ 9.0/Visual Studio 2008

Get_c_class_ip_host_id.c/C

1 /*  
2 (C) oomusou 2008 Http://oomusou.cnblogs.com
3
4 Filename: get_c_class_ip_host_id.c
5 Compiler: Visual C ++ 9.0/Visual Studio 2008
6 Description: Demo How To Get host ID of C class IP.
7 Release: 07/30/2008 1.0
8 */
9 # Include < Stdio. h >
10 # Include < String . H >
11
12 Void Get_hostid ( Char   * S, Char   * T ){
13 Char   * U = Strrchr (S, ' . ' ) +   1 ;
14 While ( * T ++ = * U ++ );
15 }
16
17 Int Main (){
18 Char S [] =   " 140.113.23.145 " ;
19 Char T [ 4 ];
20 Get_hostid (S, T );
21 Printf ( " % S " , T );
22 }

Results

145
Related Article

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.