title: C buffer overflow prevention
body: <p>I am new to programming and especially C programming. I am trying to learn C but I am really bad at it. Therefore, I hope that with all the gurus advise and guidance, I will be able to grasp it.</p>
  
  <p>I have the following code ( but it faces buffer overflow concerns ) :</p>
  
  <pre><code>char buffer[1024];
  int i=0;
  char ch;
  
  while((ch=getchar())!='\n'
  {
   If (ch==-1) break;
  Buffer[i++] = ch;
  }
  </code></pre>
  
  <p>In order to stop the buffer overflow, can I do the following ?</p>
  
  <pre><code>const int BUFFSIZE=1024;
  char ch;
  int i=0;
  while((ch=getchar())!=BUFFSIZE
  {
   If (ch==-1) break;
   BUFFSIZE[i++] = ch;
  }
  </code></pre>
  
  <p>Thank you in advance!</p>