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. Write enter character to a file

Write enter character to a file

Scheduled Pinned Locked Moved C / C++ / MFC
securitytutorialquestion
3 Posts 3 Posters 0 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.
  • G Offline
    G Offline
    gunnar66
    wrote on last edited by
    #1

    Hi Can some one show me how to write an Enter character (chr 13) to a file? HANDLE hAppend; DWORD dwBytesRead, dwBytesWritten; char buff[1]; TCHAR* filnavnhtml; hAppend = CreateFile (filnavnhtml, // Open .txt. GENERIC_WRITE, // Open for writing 0, // Do not share NULL, // No security CREATE_ALWAYS, // Open or create FILE_ATTRIBUTE_NORMAL, // Normal file NULL); // No template file // write an enter character to the file WriteFile (hAppend, buff, dwBytesRead, &dwBytesWritten, NULL);

    J D 2 Replies Last reply
    0
    • G gunnar66

      Hi Can some one show me how to write an Enter character (chr 13) to a file? HANDLE hAppend; DWORD dwBytesRead, dwBytesWritten; char buff[1]; TCHAR* filnavnhtml; hAppend = CreateFile (filnavnhtml, // Open .txt. GENERIC_WRITE, // Open for writing 0, // Do not share NULL, // No security CREATE_ALWAYS, // Open or create FILE_ATTRIBUTE_NORMAL, // Normal file NULL); // No template file // write an enter character to the file WriteFile (hAppend, buff, dwBytesRead, &dwBytesWritten, NULL);

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

      After calling CreateFile(), you'll need to call SetFilePointer(..., FILE_END) to position the file pointer to the end of the file. After that, the call to WriteFile() will look something like:

      BYTE b = 13;
      WriteFile(..., &b, 1, ...);


      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      1 Reply Last reply
      0
      • G gunnar66

        Hi Can some one show me how to write an Enter character (chr 13) to a file? HANDLE hAppend; DWORD dwBytesRead, dwBytesWritten; char buff[1]; TCHAR* filnavnhtml; hAppend = CreateFile (filnavnhtml, // Open .txt. GENERIC_WRITE, // Open for writing 0, // Do not share NULL, // No security CREATE_ALWAYS, // Open or create FILE_ATTRIBUTE_NORMAL, // Normal file NULL); // No template file // write an enter character to the file WriteFile (hAppend, buff, dwBytesRead, &dwBytesWritten, NULL);

        J Offline
        J Offline
        Jonathan Darka
        wrote on last edited by
        #3

        Hi gunnar66, Here you go... // Write a carriage return to the file DWORD dwBytesWritten = 0; BYTE obByte = 0x0d; WriteFile(m_hLogFile, obByte, 1, &dwBytesWritten, NULL)) regards, Dark Angel

        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