title: easy program checking ip - scanf segmentation fault
body: <p>I have assignment to make easy program in c which check class of IP address. My problem is that I don't work in c, and I don't know what's wrong with my program, because I don't have any IDE and everything compiles on my Debian. </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main() {
      int ip[4];
      int i=0;
  
      printf("Enter IP address: ");
  
      for(i=0;i&lt;4;i++) {
          printf("%d: ",i);
          scanf("%s",ip[i]);
      }
  
      printf("Your IP address: %03d.%03d.%03d.%03d\n",ip[0],ip[1],ip[2],ip[3]);
  
      if(ip[0]&gt;=0 &amp;&amp; ip[0]&lt;=127){
          printf("This is class A IP address\n");
          printf("Network address: %03d.0.0.0",ip[0]);
      }
      if(ip[0]&gt;127 &amp;&amp; ip[0]&lt;=191){
          printf("This is class B IP address\n");
          printf("Network address: %03d.%03d.0.0",ip[0],ip[1]);
      }
      if(ip[0]&gt;191 &amp;&amp; ip[0]&lt;224){
          printf("This is class C IP address\n");
          printf("Network address: %03d.%03d.%03d.0",ip[0],ip[1],ip[2]);
      }
  
      return 1;
      }
  </code></pre>
  
  <p>When I have this code there's segmentation fault and when in line 18 I made </p>
  
  <pre><code>scanf("%s",&amp;ip[i]); 
  </code></pre>
  
  <p>I don't have any error, but my numbers are random.</p>