In: Computer Science
c programming
Proxy IP addresses and port number are following [Ref-1]
191.96.43.58:3129
136.25.2.43:49126
198.211.96.170:3129
198.1.122.29:80
Note: THE STRING FORMATE IS "IP_Address:Port_Number ". For example, "191.96.43.58:3129" includes an IP address and a port number. "191.96.43.58" is the IP address; "3129" is the port number.
Write a program using C Structures.
If port number is 3129, please identify these IP addresses.
#include <stdio.h>
//structure declaration
struct IPAddress
{
char *address;
char *port;
};
int main()
{
//variable declaration
int i=0;
struct IPAddress ip[5];
ip[0].address = "191.96.43.58";
ip[0].port = "3129";
ip[1].address = "136.25.2.43";
ip[1].port = "49126";
ip[2].address = "198.211.96.170";
ip[2].port = "3129";
ip[3].address = "198.1.122.29";
ip[3].port = "80";
//display ip address
for(i=0; i<5; i++)
{
if(ip[i].port == "3129")
printf("%s\n", ip[i].address);
}
return 0;
}
OUTPUT:
191.96.43.58
198.211.96.170