+ 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++
5 Respuestas
+ 6
Just a note though, it is encouraged to not wave your IP address in public. Happy coding. :>
+ 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.*.
+ 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;
}
+ 1
system("ipconfig"); probably.
+ 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.