Is it possible to make an output to a file with bytes that the compiler can't read?

This is a discussion on Is it possible to make an output to a file with bytes that the compiler can't read? within the C++ Programming forums, part of the General Programming Boards category; I want to put some text into a file which the compiler can't read itself, is this possible? Like: std: ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    367

    Is it possible to make an output to a file with bytes that the compiler can't read?

    I want to put some text into a file which the compiler can't read itself, is this possible?

    Like:

    std:fstream thefile("thefile.dat");
    thefile << "The text with the incomprehensible bytes";

    I know that there are so called something with so called "null bytes" (/0) but I don't really know what these are.

    Isn't there some ANSI standard or something, can't you output every byte within this standard or is it the compiler which decides?

    Help me solve this, if there is a solution.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    A byte, singed or unsigned, only has 256 total possible values. Your compiler can output them all:

    for( x = 0; x < 255; x++ ) fputc( x, outfile );

    Not all of these are displayable in a standard text editor, if that's what you mean, but you can still write them all to a file.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  2. How can I know the actual bytes read in a file read
    By pliang in forum C++ Programming
    Replies: 1
    Last Post: 06-08-2005, 04:23 PM
  3. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 09:46 AM
  5. Simple File Creation Algorithm
    By muffin in forum C Programming
    Replies: 13
    Last Post: 08-24-2001, 03:28 PM

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