+ 1

Devise a program that will output the ip address of your computer?

ipconfig is the command for getting the ip address Use either C, js, c++

20th Apr 2018, 12:23 PM
Zacky aduoli
Zacky aduoli - avatar
7 Respostas
+ 6
Just a note though, it is encouraged to not wave your IP address in public. Happy coding. :>
20th Apr 2018, 12:28 PM
Hatsy Rei
Hatsy Rei - avatar
+ 2
Yeah, my router admin address was bookmarked and I had many static IPs in my interfaces files. I also had a script. It was easier changing the router address XD Didn't know about the 172.16.* to 172.31.* range, that was a surprise. Interesting. I only knew 10.* and 192.168.*.
22nd Apr 2018, 12:29 AM
non
+ 1
On Linux in C: /* Local network IPs - harmless */ #include <stdlib.h> int main (int argc, char **argv) { /* Local network IPs * Harmless */ system("ip address | grep inet"); system("echo "); /* External IPs * DO NOT post */ system("curl https://bot.whatismyipaddress.com"); system("echo "); return 0; }
20th Apr 2018, 1:08 PM
non
+ 1
system("ipconfig"); probably.
20th Apr 2018, 1:34 PM
Timon Paßlick
+ 1
@Martin That's why I provided a method for getting local network IPs (lo, eth, wlan) and one for your external IP and they both cheated with system(). Better shell tools. PS: 192.168.8.* was my router's default for f.u.c.* knows why. Luckily changing it was built into the web UI.
21st Apr 2018, 11:35 AM
non