Created
August 15, 2015 03:42
-
-
Save bg1bgst333/37dd98fe04bbd3e75225 to your computer and use it in GitHub Desktop.
htons#htons.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ヘッダファイルのインクルード */ | |
#include <stdio.h> /* 標準入出力 */ | |
#include <sys/types.h> /* 派生型 */ | |
#include <arpa/inet.h> /* IPアドレス変換 */ | |
/* main関数の定義 */ | |
int main(void){ | |
/* 変数の宣言 */ | |
u_short ns_port; /* ネットワークバイトオーダに変換した後のポート番号. */ | |
/* ポート番号の変換 */ | |
ns_port = htons(3000); /* ポート番号3000番をネットワークバイトオーダに変換. */ | |
/* 出力 */ | |
printf("ns_port = %04x\n", ns_port); /* ns_portを16進数で出力. */ | |
/* プログラムの終了 */ | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment