file minpulation

This is a discussion on file minpulation within the C++ Programming forums, part of the General Programming Boards category; hi everybody i am looking for a way to modify FILE (binary/HEX) representation. what i mean is : when you ...

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    12

    file minpulation

    hi everybody


    i am looking for a way to modify FILE (binary/HEX) representation.

    what i mean is :

    when you write an 'a' into a file

    then open the same file using any hexEditors

    then you will find number 61 Hex which is equal to 97 Dec

    and both are the number that equal to 'a' in the ASCII table


    -******************************-
    so what i need to write 'a'
    is to write 61 Hex to a file

    and this what i want to do using c++




    thanks

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    What have you done so far?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    12

    Unhappy

    nothing to be mentioned

    with the normal <iostream>

    i can not do anything more.
    Last edited by tharhan; 10-08-2007 at 07:26 AM.

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    To the computer, numbers and characters aren't any different, nor are hexadecimal and decimal. In the end, it comes down to numbers stored in memory in binary form, and everything else is a matter of interpretation.

    Write an 'a' to a file or write the number 97, there's no difference. The difference appears only when you use a text editor or a hex editor to open the file.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    Registered User
    Join Date
    Oct 2007
    Posts
    12
    silly me

    so the question will be changed

    *************

    how could i write one of the special characters to my file ?

    since i do not know how to write them using my keyboard

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You can write anything to a file as long as you can represent it numerically - although you will need to specify:
    Code:
    ios::binary
    The whole line may look something like this:
    Code:
    ofstream myfile ("example.bin", ios::out | ios::app | ios::binary);
    as a flag when you open the file if you don't want the certain combinations to be "changed", (such as if you open a file on Windows, it adds a '\r' when you output a '\n').

    More info here:
    http://www.cplusplus.com/doc/tutorial/files.html

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    Oct 2007
    Posts
    12

    Smile

    thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 08:35 AM
  2. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  3. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM
  4. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 01:58 AM

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