title: Initialization of character array inside constructor (Array Index Out of Bounds) in C++
body: <p>I am trying to initialise these two character arrays inside a constructor. The error is with the character arrays buf and clientip, the others are fine. I have added the code of the entire constructor below:</p>
  <pre><code>class server : public udp {
  
  public:
      server() {
  
          clientLength = 0;
          buf[1024] = {};
          bytesIn = 0;
          count = 0;
          clientIp[256] = {};
          portnumber = 0;
      }
  
  private:
      
      int clientLength = sizeof(client);
      char buf[1024];
      int bytesIn;
      int count = 0;
      char clientIp[256];
      unsigned short portnumber = 70000;
  </code></pre>
  <p>The warning is that:</p>
  <p>*(error) Array 'buf[1024]' accessed at index 1024, which is out of bounds. [arrayIndexOutOfBounds]</p>
  <p>(error) Array 'clientIp[256]' accessed at index 256, which is out of bounds. [arrayIndexOutOfBounds]*</p>
  <p>How can I solve this problem?</p>