Hy so i just made a program in C that gets the ip of the computer
struct information {
char * Usb_port;
char * ip_wlan0;
char * ip_eth0;
char * IP;
char * Date_Time;
char * host;
} ;
void get_Ip(struct information * ads)
{
int fd;
struct ifreq ifr;
///Tis code is for wlan0
fd = socket(AF_INET, SOCK_DGRAM, 0);
ifr.ifr_addr.sa_family = AF_INET;
snprintf(ifr.ifr_name, IFNAMSIZ, "wlan0");
ioctl(fd, SIOCGIFADDR, &ifr);
//define in the struct the correct ip
ads->ip_wlan0 = inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr);
close(fd);
//This code is for eth0
fd = socket(AF_INET, SOCK_DGRAM, 0);
ifr.ifr_addr.sa_family = AF_INET;
snprintf(ifr.ifr_name, IFNAMSIZ, "eth0");
ioctl(fd, SIOCGIFADDR, &ifr);
//define in the struct the correct ip
ads->ip_eth0 = inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr);
close(fd);
}
this works fine on my linux system but i am having problem to make the get_Ip() for windows, does anyone know a way for me to get the current machine ip in C for windows