title: Append text at the end of a text file in win32 api
body: <p>I am trying to open a text file, write some data into it and then append some more data at the end of the data already written to the file, but this doesnot work.
  Can anybody help me figuring out the problem with my code?
  <strong>CODE SNIPPET:</strong></p>
  
  <pre><code>char buffer[]="Write this text to file";
  DWORD dwWritten; // number of bytes written to file
  HANDLE hFile;  
  
  hFile=CreateFile("file.txt",GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
  if(hFile==INVALID_HANDLE_VALUE)
    {
      MessageBox(0,"Could not create/open a file","Error",16);
      return 0;
    }
  WriteFile(hFile,buffer,sizeof(buffer),&amp;dwWritten,0);
  
  DWORD dwPtr = SetFilePointer( hFile, dwWritten, NULL, FILE_END); //set pointer position to end file
  
  WriteFile(hFile,buffer,sizeof(buffer),&amp;dwPtr,NULL); 
  
  CloseHandle(hFile);
  </code></pre>