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.
Thanks
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.
Thanks
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.
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.