UNIX環境編程學習筆記------編程實例-----對於 函數 inet_ntop()函數的第四個參數的理解
對於 函數 inet_ntop()函數的第四個參數的理解
1.函數原型:
#include <arpa/inet.h>
const char *inet_ntop(int af, const void *src,char *dst, socklen_t size);
DESCRIPTION
This function converts the network address structure src in the af address
family into a character string. The resulting string is copied to the buffer
pointed to by dst, which must be a non-NULL pointer. The caller specifies the
number of bytes available in this buffer in the argument size.
翻譯:
這個函數把 src結構體的網絡地址轉換成一個字符串,產生的這個字符串被複制到dst所指向的緩衝區中,
調用者必須以參數大小的方式指明緩衝區的可用字節數。
1.convert convert
英 [kən'vɜːt] 美 [kən'vɝt]
vt. 使轉變;轉換…;使…改變信仰
convert sth into sth
2.resulting
英 [rɪ'zʌltɪŋ] 美 [rɪ'zʌlt]
adj. 作爲結果的
v. 致使(result的ing形式);產生
3.
. caller
英 ['kɔːlə] 美 ['kɔlɚ]
n. 訪客;[通信] 呼叫者;打電話者;召集員
adj. 新鮮的
. specify
英 ['spesɪfaɪ] 美 ['spɛsɪfaɪ]
vt. 指定;詳細說明;列舉;把…列入說明書
e. Each recipe specifies the size of egg to be used.
每種食譜都具體說明了所用雞蛋的大小。
//
我所不理解的是:這個size到底是誰的size???
解答:
size的值就是: sizeof(*dst)
即: 用於存儲字符串的緩衝區的大小。
1.函數原型:
#include <arpa/inet.h>
const char *inet_ntop(int af, const void *src,char *dst, socklen_t size);
DESCRIPTION
This function converts the network address structure src in the af address
family into a character string. The resulting string is copied to the buffer
pointed to by dst, which must be a non-NULL pointer. The caller specifies the
number of bytes available in this buffer in the argument size.
翻譯:
這個函數把 src結構體的網絡地址轉換成一個字符串,產生的這個字符串被複制到dst所指向的緩衝區中,
調用者必須以參數大小的方式指明緩衝區的可用字節數。
1.convert convert
英 [kən'vɜːt] 美 [kən'vɝt]
vt. 使轉變;轉換…;使…改變信仰
convert sth into sth
2.resulting
英 [rɪ'zʌltɪŋ] 美 [rɪ'zʌlt]
adj. 作爲結果的
v. 致使(result的ing形式);產生
3.
. caller
英 ['kɔːlə] 美 ['kɔlɚ]
n. 訪客;[通信] 呼叫者;打電話者;召集員
adj. 新鮮的
. specify
英 ['spesɪfaɪ] 美 ['spɛsɪfaɪ]
vt. 指定;詳細說明;列舉;把…列入說明書
e. Each recipe specifies the size of egg to be used.
每種食譜都具體說明了所用雞蛋的大小。
//
我所不理解的是:這個size到底是誰的size???
解答:
size的值就是: sizeof(*dst)
即: 用於存儲字符串的緩衝區的大小。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.