write in a binary file

This is a discussion on write in a binary file within the C++ Programming forums, part of the General Programming Boards category; hi guys now the thing is simple i want to write binary data to a binary file for example i ...

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    2

    write in a binary file

    hi guys
    now the thing is simple
    i want to write binary data to a binary file

    for example
    i wanna get a string length strlen(str)
    then convert this length to binary e.g. 2 == 00000010

    then write this length to a file as 1 byte "00000010 is one byte "
    so i think we will use binary file

    the problem is that i don't know how to get the length in binary and how to write this to a file in one byte length

    any idea ???

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    1. to write binary file - open file as binary
    2. length is longer than 1 byte (4 bytes I suppose) so writing it using bynary write will write (depending on the size of size_t type) 4 bytes to your file...
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 05:14 AM
  2. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 02:19 PM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 09:39 AM
  4. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 04:39 AM
  5. copying binary file
    By samc2004 in forum C Programming
    Replies: 5
    Last Post: 12-09-2003, 01:34 PM

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