title: Try to write char[] to a text file
body: <p>I trying to write a char[256] to a text file. Below is my current work:</p>
  
  <pre><code>         fstream ofs;
           ofs.open("c:\\myURL.txt");
           ofs.write((char*)testDest,256); 
           ofs.close();
  </code></pre>
  
  <p>It still does not work.</p>
  
  <p>here is the error:</p>
  
  <p>error C2440: 'type cast' : cannot convert from '' to 'char *'</p>
  
  <p>update:</p>
  
  <p>so far, here is my progress attempt, the code can compile, but when running, my program suddenly terminated.</p>
  
  <pre><code>    ofstream stream;
      CBar *a;
  
      switch(uMessage) {
      case WM_PAINT:
          return bar-&gt;OnPaint();
      case WM_ERASEBKGND:
          return 1;
      case WM_LBUTTONDOWN:   //wira
             if (!bar-&gt;OnClick(wParam, lParam)) {
          stream.open("C:\\myURL.txt");
          stream &lt;&lt; a-&gt;testDest &lt;&lt; endl;    // if I replace `a-&gt;testDest` with "testword" string, my prgrom does not terminated. Why?
          return 0;
          }
          break;
  </code></pre>