You are here

C program to get ip address

C program to print IP (Internet Protocol) address of your computer, system function is used to execute the command "ipconfig" which prints IP address, subnet mask and default gateway. The code given below works for Windows XP and Windows 7. If you are using Turbo C compiler then execute this program from folder, it may not work when you are working in compiler and trying to execute it by Ctrl + F9.

C programming code

#include<stdlib.h>
 
int main()
{
   system("C:\\Windows\\System32\\ipconfig");
 
   return 0;
}

Download IP address program.

Output of program: ( In Windows 7)
IP address program

Only part of output is shown in image.