title: Pointer error ? Access violating memory read
body: <p>I have to help one of my friends, but I have forgotten a bit C. :\ Whats the problem with that code? there must be some pointer error. It gives me an Access violating reading memory. What could be the problem? The main task is to: 2 unlimited arrays, and have to count an avarge.  </p>
  
  <p>Edited version: the reading is ok, but can pass literaly fine. As I remember I shouldn't return a pointer, Could I return a counter to count how many numbers attached to A and B array?   </p>
  
  <pre><code>    #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  double *bekerdezo1(double *a){
      char line[64];
      double value = 0;
      int n = 0;
      while ((fgets(line, sizeof line, stdin) != NULL) &amp;&amp; (line[0] != '\n')){
          if (sscanf(line, "%lf", &amp;value) == 1){
              a =(double*)malloc(sizeof(*a) *(n+1));
              a[n] = value;
              printf("%lf",a[n]);
              n = n++;
          } 
          else {
              break;
          }
      }
      return a;
  }
  double *bekerdezo2(double *b){
      double value = 0;
      char line[64];
      int n = 0;
      while ((fgets(line, sizeof line, stdin) != NULL) &amp;&amp; (line[0] != '\n')){
          if (sscanf(line, "%lf", &amp;value) == 1){
              b = (double*)malloc(sizeof(*b) *(n+1));
              b[n] = value;
              printf("%lf",b[n]);
              n = n++;
          } else {
              break;
          }
      }
      return b;
  }
  
  int main(void)
  {
  
  double reszq = 0,vegosszeg=0, tarolo = 0; 
  int i = 0;
  size_t *n = 0;
  double *a=NULL, *b = NULL;
  
  bekerdezo1(a);
  bekerdezo2(b);
  
  for(i=0;i&lt;100; i++)
  {
      reszq = 0;
      tarolo = (a[i])*(b[i]);
      reszq = tarolo/a[i];
      vegosszeg = vegosszeg + reszq;
  }
  printf("vegosszeg=", vegosszeg);
  
  
  return 0;
  }
  </code></pre>