ReadFile and binary data

This is a discussion on ReadFile and binary data within the Windows Programming forums, part of the Platform Specific Boards category; a question: in DOS programming you can read/write a file in either ascii or binary mode. which mode do the ...

  1. #1
    Registered User
    Join Date
    Sep 2001

    Question ReadFile and binary data

    a question: in DOS programming you can read/write a file in either ascii or binary mode. which mode do the windows functions use? i suppose it detects which mode it needs to use.
    also, when i read data from a file, the data usually has both characters (ascii) and numbers (integers). how can i detect if a byte of data is supposed to be an integer rather than a character? i hope you understand my question. i wrote a program to record the ascii number of every byte in a file (using "(int) char"), and the byte that contained the integer 19 returned a 19, is there a way to distiguish this from "DC3," which is the character associated with ascii code 19?

  2. #2
    train spotter
    Join Date
    Aug 2001
    near a computer
    Sounds more like a problem in your ascii to int function.
    Are you sure you are only sending in one char at a time not giving it a pointer to the rest of the file buffer?
    Try copying a single char from the buffer to a seperate variable (ie char cChar; ) and converting that.
    Best way is to GetFileSize(), GlobalAlloc() this +1 chars (bytes) and read the whole file, at once, to this buffer.
    Close the file.
    copy single char to temp single char buffer
    increment index
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fread readfile
    By samsam1 in forum Windows Programming
    Replies: 3
    Last Post: 02-03-2003, 02:14 PM
  2. I want binary compare
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 06-06-2002, 09:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21