How to pass an IP address to inet_addr?
- by November
I can't seem to pass an IP address to inet_addr. I have gone through the debug but I still can't figure out why this won't work.
printf("Server IP\nIP:");
scanf("%s",cmdPtr);
//Bind socket
address.sin_family = AF_INET;
address.sin_addr.s_addr = inet_addr(&cmdPtr);
address.sin_port = htonl(SERVER_PORT);
lenC = sizeof(address);
if (connect(sdC, (struct sockaddr *) &address , lenC) < 0) {
perror("Could not bind Socket\n");
return -1;
}