title: Different behaviour of fread() on online editor and the local machine (C++)
body: <p>When I use <code>fread()</code> in a C++ code and compile it (using gcc) on online editors, it works fine. But when I run the same code on my local machine, it waits infinitely unless I hit ctrl+z on my windows PC. Why is it so?</p>
  
  <p>I'm reading from stdin in the code (in case this helps).</p>
  
  <p>Here is the code (its not mine, though. I'm just using it to understand it).</p>
  
  <pre><code>#include&lt;cstdio&gt;
  #include&lt;iostream&gt;
  #include&lt;cstdlib&gt;
  using namespace std;
  #define size 65536
  int main()
  {
  
  char b[size];
  int t=0,n,k,cnt=0;
  int c,j;
  scanf("%d %d\n",&amp;n,&amp;k);
  printf("%d %d\n", n, k);
  while((c = fread(b,1,size,stdin))&gt;0)
  {
       printf("%d\n",c);
             for(j=0;j&lt;c;j++)
             {
              if(b[j]=='\n')
              {
                            if(t%k==0)cnt++;
                            t = 0;
              }
              else
              {
                            t = (t*10) + (b[j]-'0');                
              }              
             }
   }
  printf("%d\n",cnt);    
  return 0;
  }
  </code></pre>