title: Converting IP Address input by using inet_ntop() & inet_pton() (C PROGRAMMING)
body: <p>i'm trying to convert an IP address that's inputted by a user so that I can perform some bitwise operations on it and a address already stored in a structure. My problem is however that when the IP address is converted back the output is always 255.255.255.255. For example a input of 10.0.0.1 or 192.16.2.1 always returns 255.255.255.255.</p>
  
  <p>Any help would be appreciated. THANKS    </p>
  
  <pre><code>  {
          struct sockaddr_in sa;
          char ipinput[INET_ADDRSTRLEN];
  
          fputs("Enter an IP Address: ", stdout);
          fflush(stdout);
          fgets(ipinput, sizeof ipinput, stdin);
          inet_pton(AF_INET, ipinput, &amp;(sa.sin_addr));
          inet_ntop(AF_INET, &amp;(sa.sin_addr), ipinput, INET_ADDRSTRLEN);
          printf("IP Address = \%s\ \n", ipinput);
          }
  </code></pre>