Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Writing Data to an Open File

Writing Data to an Open File

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Freddie Code
    wrote on last edited by
    #1

    In VC++6 MFC I'm using the CFileDialog Class to get a filename from the user as in the code below. How do I write ASCII data to the file that is returned. How can I write "Hello World" to the file. Can I use fprintf? What would the file handle be? char strFilter[] = { "CANMon Files (*.canmon)|*.canmon|All Files (*.*)|*.*||" }; CString canLogFile; CFileDialog FileDlg(FALSE, ".bcr", NULL, 0, strFilter); if( FileDlg.DoModal() == IDOK ) { f.Open(FileDlg.GetFileName(), CFile::modeCreate | CFile::modeWrite); CArchive ar(&f, CArchive::store); canLogFile = FileDlg.GetFileName(); sprintf(szPrintString, canLogFile); m_logboxTestVariable.AppendString (canLogFile); }

    D 1 Reply Last reply
    0
    • F Freddie Code

      In VC++6 MFC I'm using the CFileDialog Class to get a filename from the user as in the code below. How do I write ASCII data to the file that is returned. How can I write "Hello World" to the file. Can I use fprintf? What would the file handle be? char strFilter[] = { "CANMon Files (*.canmon)|*.canmon|All Files (*.*)|*.*||" }; CString canLogFile; CFileDialog FileDlg(FALSE, ".bcr", NULL, 0, strFilter); if( FileDlg.DoModal() == IDOK ) { f.Open(FileDlg.GetFileName(), CFile::modeCreate | CFile::modeWrite); CArchive ar(&f, CArchive::store); canLogFile = FileDlg.GetFileName(); sprintf(szPrintString, canLogFile); m_logboxTestVariable.AppendString (canLogFile); }

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Freddie Code wrote: How do I write ASCII data to the file that is returned. Use CFile::Write() or CStdioFile::WriteString().


      "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups