title: How to copy string to clipboard in C?
body: <p>The <code>SetClipboardData</code> function requires a <code>HANDLE</code> reference; I'm having trouble converting my string for use in the function.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>char* output = "Test";
  HLOCAL hMem =  LocalAlloc( LHND,1024);
  char* cptr = (char*) LocalLock(hMem);
  memcpy( cptr, output, 500 );
  SetClipboardData(CF_TEXT, hMem);
  LocalUnlock( hMem );
  LocalFree( hMem );
  CloseClipboard();
  </code></pre>
  
  <p>What am I doing wrong here and what's the proper way to do it?</p>
  
  <p>Thanks.</p>