Thread: converting text to binary

  1. #1
    Registered User
    Join Date
    Feb 2006

    converting text to binary

    I am building a c++ program and I need to locate a particular file by the user entering the name of the file and then the program finds the file and outputs it either binary or assembler format any help would be appriciated.

  2. #2
    Registered User
    Join Date
    Aug 2005
    First, there is no such thing as "assembler" file format. See fstream for your other questions -- there are millions of examples on these boards if you just take the time to browse around.

  3. #3
    Hardware Engineer
    Join Date
    Sep 2001

    Thumbs down

    What do you mean by "binary?".

    In C++ there are two different meanings of "binary."

    When we speak of reading or writing to a file in binary, this is simply the normal "raw" data mode. The other mode is the special text mode, where the data is formatted as text. (Line-feeds and/or carrage-returns replace null-terminations, etc.)

    The other meaning (what the word binary means to most people) is "base-2". Decimal, Octal, and Hexadecimal are easy in C++. Base-2 is tricky. (There is a special STL container class called <bitset> for base-2.)

    Normally if you want to "look-at" the binary (base-2) data, you will use hex. Hex is easier to read than binary (especially with 32-bit numbers), yet is is easy to convert between binary and hex. You can learn to do it in your head. If you simply want to look at the raw data in a file, you can open it with a hex editor. Here's a link to a free hex editor.

    If you want to look at the assembly code for a program file, you can get a disassembler, which you should also be able to find free on the Net, if your IDE (compiler package) doesn't have one.
    Last edited by DougDbug; 02-14-2006 at 04:59 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 02:59 PM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. Converting Sign Magnitude Integer Binary Files
    By Arthur Dent in forum C Programming
    Replies: 7
    Last Post: 09-13-2004, 10:07 AM
  4. converting to CAPS from a text file
    By axon in forum C++ Programming
    Replies: 2
    Last Post: 03-03-2003, 07:30 PM
  5. Convert a text file to a binary file
    By Cyber Kitten in forum C Programming
    Replies: 16
    Last Post: 02-04-2002, 08:53 AM