title: C : buffer and pointers
body: <p>I'm writing a little program that must:</p>
  
  <ol>
  <li>Ask a user how many numbers he will enter (to stock in 2 tab dynamically)</li>
  <li>Enter numbers step by step and the number go in the bufferP if he is positive and in bufferN if negative</li>
  <li>If there is no more place in a buffer, double the size of this one</li>
  <li>Finally printf both buffers</li>
  </ol>
  
  <p>Here is my code: </p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  
  int main(){
      int length = 0;
      printf("Number of data: \n");
      scanf("%d", &amp;length);
      int *bufferP = (int*)malloc(2*sizeof(int));
      int *bufferN = (int*)malloc(2*sizeof(int));
      int number = 0;
      for (int i = 0 ; i &lt;= length ; i++){
          scanf("%d", &amp;number);
          if(number &lt; 0){
              if(*bufferN == NULL){
                  printf("No more place");
                  exit(0);
              }
              *bufferN= number;
              *bufferN++;
          }
  
          if(number &gt;= 0){
              if(*bufferP == NULL){
                  printf("No more place");
  
              }
              *bufferP = number;
              *bufferP++;
          }
  
      }
  
      int res =0;
      printf("tab negative : ");
      for (int i = 0; bufferN[i] != NULL; i++)
      {
          res = bufferN[i]; 
          printf("%d\n", res );
      }
      printf("tab positive : ");
      for (int i = 0; bufferP[i] != NULL; i++)
      {
          res = bufferP[i]; 
          printf("%d\n", res );
      }
  }
  </code></pre>
  
  <p>I've got those errors :</p>
  
  <pre><code> In function ‘main’:
  rev_S3_ptr.c:14:16: error: comparison between pointer and integer [-Werror]
      if(*bufferN == NULL){
                  ^~
  rev_S3_ptr.c:19:4: error: value computed is not used [-Werror=unused-value]
      *bufferN++;
      ^~~~~~~~~~
  rev_S3_ptr.c:23:16: error: comparison between pointer and integer [-Werror]
      if(*bufferP == NULL){
                  ^~
  rev_S3_ptr.c:28:4: error: value computed is not used [-Werror=unused-value]
      *bufferP++;
      ^~~~~~~~~~
  rev_S3_ptr.c:35:29: error: comparison between pointer and integer [-Werror]
    for (int i = 0; bufferN[i] != NULL; i++)
                               ^~
  rev_S3_ptr.c:41:29: error: comparison between pointer and integer [-Werror]
    for (int i = 0; bufferP[i] != NULL; i++)
  </code></pre>
  
  <p>So my question are:</p>
  
  <ol>
  <li>The buffer works like a tab right ? So why can't I just say that if the pointer is null it is full and do *buffer ++ ?</li>
  <li>At the "No more place" I must double the size of the buffer and I don't know how to do this.</li>
  </ol>