Vimzy
Vimzy

Reputation: 1985

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.

Upvotes: 0

Views: 632

Answers (1)

Haris
Haris

Reputation: 12272

You can do

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

Upvotes: 3

Related Questions