简体   繁体   中英

How to store human readable IP in struct in_addr?

Say if you have the following IP address:

192.168.0.255

How can I store that human readable IP address into a struct in_addr ? I'm brand new to network programming in C at this low level, so any help would be greatly appreciated.

You can do

struct in_addr p;
inet_aton("192.168.0.255", &p.s_addr);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM