title: What difference does it make to use "%1d" instead of "%d" only in scanf statement?
body: <p><a href="https://www.codechef.com/problems/LCOLLIS" rel="nofollow noreferrer">https://www.codechef.com/problems/LCOLLIS</a></p>
  
  <p>I was solving the above problem on codechef and I wrote the below code for it but it gave me runtime error (SIGSEVG).</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int main(void)
  {
  int t, n, m;
  scanf("%d", &amp;t);
  
  while(t--)
  {
      scanf("%d %d", &amp;n, &amp;m);
  
      int a[10][10], i, j, sum, ans;
  
      for(i = 0; i &lt; n; i++)
      {
          for(j = 0; j &lt; m; j++)
              scanf("%d", &amp;a[i][j]);
      }
  
      ans = 0;
      for(i = 0; i &lt; m; i++)
      {
          sum = 0;
          for(j = 0; j &lt; n; j++)
          {
              if(a[j][i] == 1)
                  sum++;
          }
  
  
          if(sum &gt; 1)
              ans = ans + ( sum * (sum - 1) ) / 2;
      }
  
      printf("%d\n", ans);
  }
  
  return 0;
  }
  </code></pre>
  
  <p>And I saw one of the solutions that was exactly same as mine just with a little difference and it was accepted. The code is the following :</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int main(void)
  {
  int t, n, m;
  scanf("%d", &amp;t);
  
  while(t--)
  {
      scanf("%d %d", &amp;n, &amp;m);
  
      int a[10][10], i, j, sum, ans;
  
      for(i = 0; i &lt; n; i++)
      {
          for(j = 0; j &lt; m; j++)
              scanf("%1d", &amp;a[i][j]); // SEE RIGHT HERE ITS JUST A 1 BEFORE d
      }
  
      ans = 0;
      for(i = 0; i &lt; m; i++)
      {
          sum = 0;
          for(j = 0; j &lt; n; j++)
          {
              if(a[j][i] == 1)
                  sum++;
          }
  
  
          if(sum &gt; 1)
              ans = ans + ( sum * (sum - 1) ) / 2;
      }
  
      printf("%d\n", ans);
  }
  
  return 0;
  }
  </code></pre>
  
  <p>Now I couldn't understand how that 1 makes all the difference.
  Please someone help me out.</p>