Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,880 questions

51,806 answers

573 users

How to store IP address in C

1 Answer

0 votes
#include <stdio.h>
#include <stdint.h>

union {
    struct {
        uint8_t first:8;
        uint8_t second:8;
        uint8_t third:8;
        uint8_t fourth:8;
    };
    uint32_t ip;
} typedef IPAddress;

int main() {

    IPAddress ip = {{127,55,7,3}};

    printf("%d.%d.%d.%d\n", ip.first, ip.second, ip.third, ip.fourth);


    return 0;
}




/*
run:

127.55.7.3

*/

 



answered May 6, 2021 by avibootz

Related questions

4 answers 205 views
205 views asked May 15, 2024 by avibootz
1 answer 214 views
1 answer 234 views
2 answers 233 views
233 views asked May 22, 2015 by avibootz
1 answer 184 views
1 answer 89 views
...