Programming with Passion

Make the best out of everything.

Saturday 19 March 2016

Get IP Address in C++

Get IP Address in C++

To find/get and display the IP address of your computer in C++ programming, use the function system() and place the command ipconfig after providing the full path of System32 i.e., C:\\Windows\\System32\\ipconfiginside it which calls the windows Command Prompt (cmd) to find/get and display the IP address as shown here in the following program.

C++ Programming Code to Get IP Address

Following C++ program get the IP Address and display it on the screen:
/* C++ Program - Get IP Address */
  
#include<conio.h>
#include<stdlib.h>
void main()
{
 clrscr();
 
 system("C:\\Windows\\System32\\ipconfig");
 
 getch();
}
When the above C++ program is compile and executed, it will produce the following result:
C++ program to get ip address

No comments:

Post a Comment