title: C subscripted value is neither array nor pointer nor vector
body: <pre><code>int * matrixsum(int *a,int *b,int n,int m)
  {
      int *p=NULL,i,j;
      p=malloc(sizeof(int)*n*m);
      if(p==NULL)
      {
          printf("Error!\n");
          exit(1);
      }
      for(i=0;i&lt;n;i++)
      {
          for(j=0;j&lt;m;j++)
          {
              *(p+i*n+j)=*(a+i*n+j)+*(b+i*n+j);
          }
      }
      return p;
  }
  </code></pre>
  
  <p>My question is about the line <code>*(p+i*n+j)=*(a+i*n+j)+*(b+i*n+j);</code>: if I replace it with <code>p[i][j]=a[i][j]+b[i][j];</code> I get the following error 3 times:</p>
  
  <blockquote>
    <p>error: subscripted value is neither array nor pointer nor vector</p>
  </blockquote>
  
  <p>Why? From my knowledge they are the same thing.</p>
  
  <p>My compiler is gcc version 4.6.3.</p>