How to get IP address in C

2 Answers

0 votes
#include <stdio.h>
#include <stdlib.h> 
 
int main() { 
    system("C:\\Windows\\System32\\ipconfig");
 
    return(0);
}
 
 
/*
run:
  
Windows IP Configuration
 
 
Ethernet adapter Ethernet:
 
   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : ae00::6010:a000:5300:7101%3
   IPv4 Address. . . . . . . . . . . : 123.123.1.12
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 123.123.1.1
 
*/


answered May 22, 2015 by avibootz
edited Jul 14, 2020 by avibootz
0 votes
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main() {
   execl("c:\\windows\\system32\\ipconfig", "ipconfig", (char *)0);
   
   return 0;
}           
              
              
/*
run:
              
Windows IP Configuration


Ethernet adapter Ethernet:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : ae00::6010:a000:5300:7101%3
   IPv4 Address. . . . . . . . . . . : 123.123.1.12
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 123.123.1.1
         
*/

 



answered Jul 14, 2020 by avibootz

Related questions

4 answers 283 views
283 views asked May 15, 2024 by avibootz
1 answer 196 views
196 views asked May 6, 2021 by avibootz
1 answer 244 views
1 answer 263 views
1 answer 112 views
2 answers 181 views
1 answer 181 views
181 views asked Feb 21, 2019 by avibootz
...