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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem with WriteFile

Problem with WriteFile

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionc++
5 Posts 4 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.
  • D Offline
    D Offline
    Deepak Samuel
    wrote on last edited by
    #1

    Hi, I am sorry that I am asking a question not relevant to this section of MessageBoard, but I hope that somebody can help me out. I use the WriteFile function in my MFC application to write data to a File from a Buffer. When I see open the file, I see strange characters, while my data in the Buffer contains only numbers. What can be the problem? Thanks in Advance, Deepak Samuel

    D A 2 Replies Last reply
    0
    • D Deepak Samuel

      Hi, I am sorry that I am asking a question not relevant to this section of MessageBoard, but I hope that somebody can help me out. I use the WriteFile function in my MFC application to write data to a File from a Buffer. When I see open the file, I see strange characters, while my data in the Buffer contains only numbers. What can be the problem? Thanks in Advance, Deepak Samuel

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

      A code snippet showing how you are writing to the file would be nice. How are you viewing the file once it's been written to?


      Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

      D 1 Reply Last reply
      0
      • D Deepak Samuel

        Hi, I am sorry that I am asking a question not relevant to this section of MessageBoard, but I hope that somebody can help me out. I use the WriteFile function in my MFC application to write data to a File from a Buffer. When I see open the file, I see strange characters, while my data in the Buffer contains only numbers. What can be the problem? Thanks in Advance, Deepak Samuel

        A Offline
        A Offline
        Adam Gritt
        wrote on last edited by
        #3

        It depends on how you open the file. Do you open it as text or binary? If you open it as binary you would see strange characters because you would be seeing the ascii interpretation of what the numeric values are. For instantce if you output the number 32 as binary it would appear as a space in a text file.

        1 Reply Last reply
        0
        • D David Crow

          A code snippet showing how you are writing to the file would be nice. How are you viewing the file once it's been written to?


          Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

          D Offline
          D Offline
          Deepak Samuel
          wrote on last edited by
          #4

          hDataFile = CreateFile( DataFilename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); pWin_Data[0] = (PWINDATA)WinBuff_1_Address; WriteFile( hDataFile, pWin_Data[0], sizeof(ULONG), ptr, NULL ); CloseHandle( hDataFile); The File name is with the extension ".dat" and I opened it with notepad. Deepak Samuel.

          R 1 Reply Last reply
          0
          • D Deepak Samuel

            hDataFile = CreateFile( DataFilename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); pWin_Data[0] = (PWINDATA)WinBuff_1_Address; WriteFile( hDataFile, pWin_Data[0], sizeof(ULONG), ptr, NULL ); CloseHandle( hDataFile); The File name is with the extension ".dat" and I opened it with notepad. Deepak Samuel.

            R Offline
            R Offline
            Roger Allen
            wrote on last edited by
            #5

            It looks like your code is writing a pointer address to the file. Is this the intention? If you want what the pointer is pointing to, use *(pWin_Data[0]) Roger Allen - Sonork 100.10016 If your dead and reading this, then you have no life!

            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