title: how do i chunk a 1000MB file using mmapdemo
body: <p>I'm following a tutorial from BeeJ's website and i've learnt quite a bit of it.</p>
  <p>I'm in that stage of experimentation and want to somehow build upon this code.</p>
  <p>In short, say the user types an address: 1050576 for a file that's roughly 1000MB, the program (shown below) should map the chunk in the file data up to a position where 1050576 falls between chunk beginning and its length.</p>
  <p>When i run the code, it says the max address size is 924 and so i can't really chunk a file that's 1000mb.</p>
  <p>Could someone help explain / provide an example on how i can tackle this?</p>
  <pre><code>/*
  ** mmapdemo.c -- demonstrates memory mapped files lamely.
  */
  
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;fcntl.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/mman.h&gt;
  #include &lt;sys/stat.h&gt;
  #include &lt;errno.h&gt;
  
  int main(int argc, char *argv[])
  {
      int fd, offset;
      char *data;
      struct stat sbuf;
  
      if (argc != 2) {
          fprintf(stderr, &quot;usage: mmapdemo offset\n&quot;);
          exit(1);
      }
  
      if ((fd = open(&quot;mmapdemo.c&quot;, O_RDONLY)) == -1) {
          perror(&quot;open&quot;);
          exit(1);
      }
  
      if (stat(&quot;mmapdemo.c&quot;, &amp;sbuf) == -1) {
          perror(&quot;stat&quot;);
          exit(1);
      }
  
      offset = atoi(argv[1]);
      if (offset &lt; 0 || offset &gt; sbuf.st_size-1) {
          fprintf(stderr, &quot;mmapdemo: offset must be in the range 0-%ld\n&quot;, sbuf.st_size-1);
          exit(1);
      }
  
      if ((data = mmap((caddr_t)0, sbuf.st_size, PROT_READ, MAP_SHARED, fd, 0)) == (caddr_t)(-1)) {
          perror(&quot;mmap&quot;);
          exit(1);
      }
  
      printf(&quot;byte at offset %d is '%c'\n&quot;, offset, data[offset]);
  
      return 0;
  }
  </code></pre>