title: Write Failed: Bad address
body: <pre><code>/* Write and rewrite */
  #include&lt;stdio.h&gt;
  #include&lt;unistd.h&gt;
  #include&lt;sys/types.h&gt;
  #include&lt;sys/stat.h&gt;
  #include&lt;fcntl.h&gt;
  
  int main(int argc,char* argv[]){
   int i = 0;
   int w_rw = 0;
   int fd = -1;
   int bw = -1;
   int nob = 0;
   char* file_name = "myfile";
   char buff[30] = "Dummy File Testing";
  
   w_rw = 1;       // 1 - write , 2 - rewrite
   nob = 1000000;  // No of bytes to write
  
   printf("\n File - Create,Open,Write \n");
  
   for(i = 0; i &lt; w_rw; i++){
          printf("fd:%d line : %d\n",fd,__LINE__);
          if((fd = open(file_name,O_CREAT | O_RDWR))&lt; 0){
                  perror("Open failed!");
                  return -1;
          }
  
          printf("fd:%d",fd);
          if((bw = write(fd,buff,nob)) &lt; 0){
                  perror("Write failed!");
                  return -1;
          }
          printf("\n Bytes written : %d \n",bw);
   }
  
   return 0;
  }
  </code></pre>
  
  <p>I'm getting a write error, Bad address failure when tried to write 1MB bytes of data. why is that so ?</p>