EOF

Discussion in 'C++' started by Salman, Mar 11, 2007.

  1. Salman

    Salman Guest

    Hi,
    We usually read file until we get EOF character.
    How EOF look like? i want to put EOF character at the start of my data
    file, so that no one can read that file use as he will get EOF at the
    start of file.

    Tell me how can i do this?

    ive used the following program but its not working.

    -----------------------------------
    fstream fout;
    fout.open("a.txt");
    char temp = EOF;
    f<<temp;
    Salman, Mar 11, 2007
    #1
    1. Advertising

  2. Salman wrote:
    > Hi,
    > We usually read file until we get EOF character.
    > How EOF look like? i want to put EOF character at the start of my data
    > file, so that no one can read that file use as he will get EOF at the
    > start of file.
    >
    > Tell me how can i do this?
    >
    > ive used the following program but its not working.
    >
    > -----------------------------------
    > fstream fout;
    > fout.open("a.txt");
    > char temp = EOF;
    > f<<temp;
    >


    There is no EOF character, so this cannot be done.

    EOF is a special value which is *different* from any character.

    john
    John Harrison, Mar 11, 2007
    #2
    1. Advertising

  3. Salman

    Salman Guest

    On Mar 11, 1:36 pm, John Harrison <> wrote:
    > Salman wrote:
    > > Hi,
    > > We usually read file until we get EOF character.
    > > How EOF look like? i want to put EOF character at the start of my data
    > > file, so that no one can read that file use as he will get EOF at the
    > > start of file.

    >
    > > Tell me how can i do this?

    >
    > > ive used the following program but its not working.

    >
    > > -----------------------------------
    > > fstream fout;
    > > fout.open("a.txt");
    > > char temp = EOF;
    > > f<<temp;

    >
    > There is no EOF character, so this cannot be done.
    >
    > EOF is a special value which is *different* from any character.
    >
    > john- Hide quoted text -
    >
    > - Show quoted text -


    Any alternitive way of accomplishing this task???
    Salman, Mar 11, 2007
    #3
  4. Salman wrote:
    > On Mar 11, 1:36 pm, John Harrison <> wrote:
    >
    >>Salman wrote:
    >>
    >>>Hi,
    >>>We usually read file until we get EOF character.
    >>>How EOF look like? i want to put EOF character at the start of my data
    >>>file, so that no one can read that file use as he will get EOF at the
    >>>start of file.

    >>
    >>>Tell me how can i do this?

    >>
    >>>ive used the following program but its not working.

    >>
    >>>-----------------------------------
    >>>fstream fout;
    >>>fout.open("a.txt");
    >>>char temp = EOF;
    >>>f<<temp;

    >>
    >>There is no EOF character, so this cannot be done.
    >>
    >>EOF is a special value which is *different* from any character.
    >>
    >>john- Hide quoted text -
    >>
    >>- Show quoted text -

    >
    >
    > Any alternitive way of accomplishing this task???
    >


    What are you trying to do? Are you just trying to make a file of zero
    length. This code will do that.

    void make_zero_length_file()
    {
    ofstream fout("a.txt");
    }

    Or are you trying to make a file which is not zero length but which C++
    thinks is zero length? There is no way to do that.

    john
    John Harrison, Mar 11, 2007
    #4
  5. Salman

    Salman Guest

    On Mar 11, 2:04 pm, John Harrison <> wrote:
    > Salman wrote:
    > > On Mar 11, 1:36 pm, John Harrison <> wrote:

    >
    > >>Salman wrote:

    >
    > >>>Hi,
    > >>>We usually read file until we get EOF character.
    > >>>How EOF look like? i want to put EOF character at the start of my data
    > >>>file, so that no one can read that file use as he will get EOF at the
    > >>>start of file.

    >
    > >>>Tell me how can i do this?

    >
    > >>>ive used the following program but its not working.

    >
    > >>>-----------------------------------
    > >>>fstream fout;
    > >>>fout.open("a.txt");
    > >>>char temp = EOF;
    > >>>f<<temp;

    >
    > >>There is no EOF character, so this cannot be done.

    >
    > >>EOF is a special value which is *different* from any character.

    >
    > >>john- Hide quoted text -

    >
    > >>- Show quoted text -

    >
    > > Any alternitive way of accomplishing this task???

    >
    > What are you trying to do? Are you just trying to make a file of zero
    > length. This code will do that.
    >
    > void make_zero_length_file()
    > {
    > ofstream fout("a.txt");
    >
    > }
    >
    > Or are you trying to make a file which is not zero length but which C++
    > thinks is zero length? There is no way to do that.
    >
    > john- Hide quoted text -
    >
    > - Show quoted text -


    Yes im trying to make a file of zero length which is actually of not
    zero length. I want to put EOF at the start of my file to make it zero
    length so that no one can copy that file. coz copy function in the
    windows plateform read the files up to EOF. So if i put EOF (which as
    u said that its not a character , its a condition) at the start of the
    my file, so no one can copy that file.

    Anyhow, is there any other way, any solution, though which i can make
    a file so that no one can copy that file. He can only read that file.
    Any idea?
    Salman, Mar 11, 2007
    #5
  6. Salman

    Sheth Raxit Guest

    On Mar 11, 1:32 pm, "Salman" <> wrote:
    > Hi,
    > We usually read file until we get EOF character.
    > How EOF look like?

    why dont you print, EOF?

    >i want to put EOF character at the start of my data

    you should not do that.
    > file, so that no one can read that file use as he will get EOF at the
    > start of file.

    better use good encryption technique,
    even If you do this successfully if I come to know the file is created
    like this way I can read the data,(by removing first null char.!) --
    This may be virtual situation! :) --
    >
    > Tell me how can i do this?
    >
    > ive used the following program but its not working.

    not working means ? can you write down "Should be output and Actual
    output"
    >
    > -----------------------------------
    > fstream fout;
    > fout.open("a.txt");
    > char temp = EOF;
    > f<<temp;


    --Raxit
    Sheth Raxit, Mar 11, 2007
    #6
  7. Salman wrote:
    > On Mar 11, 2:04 pm, John Harrison <> wrote:
    >
    >>Salman wrote:
    >>
    >>>On Mar 11, 1:36 pm, John Harrison <> wrote:

    >>
    >>>>Salman wrote:

    >>
    >>>>>Hi,
    >>>>>We usually read file until we get EOF character.
    >>>>>How EOF look like? i want to put EOF character at the start of my data
    >>>>>file, so that no one can read that file use as he will get EOF at the
    >>>>>start of file.

    >>
    >>>>>Tell me how can i do this?

    >>
    >>>>>ive used the following program but its not working.

    >>
    >>>>>-----------------------------------
    >>>>>fstream fout;
    >>>>>fout.open("a.txt");
    >>>>>char temp = EOF;
    >>>>>f<<temp;

    >>
    >>>>There is no EOF character, so this cannot be done.

    >>
    >>>>EOF is a special value which is *different* from any character.

    >>
    >>>>john- Hide quoted text -

    >>
    >>>>- Show quoted text -

    >>
    >>>Any alternitive way of accomplishing this task???

    >>
    >>What are you trying to do? Are you just trying to make a file of zero
    >>length. This code will do that.
    >>
    >>void make_zero_length_file()
    >>{
    >> ofstream fout("a.txt");
    >>
    >>}
    >>
    >>Or are you trying to make a file which is not zero length but which C++
    >>thinks is zero length? There is no way to do that.
    >>
    >>john- Hide quoted text -
    >>
    >>- Show quoted text -

    >
    >
    > Yes im trying to make a file of zero length which is actually of not
    > zero length. I want to put EOF at the start of my file to make it zero
    > length so that no one can copy that file. coz copy function in the
    > windows plateform read the files up to EOF. So if i put EOF (which as
    > u said that its not a character , its a condition) at the start of the
    > my file, so no one can copy that file.
    >
    > Anyhow, is there any other way, any solution, though which i can make
    > a file so that no one can copy that file. He can only read that file.
    > Any idea?
    >


    If you are programming Windows then you need to set the access
    permissions so that no-one apart from yourself can read the file.

    But this isn't a C++ question, it's a Windows programming question. You
    should ask on comp.os.ms-windows.programmer.win32

    john
    John Harrison, Mar 11, 2007
    #7
  8. Salman

    David Harmon Guest

    On 11 Mar 2007 01:28:46 -0800 in comp.lang.c++, "Salman"
    <> wrote,
    >Anyhow, is there any other way, any solution, though which i can make
    >a file so that no one can copy that file. He can only read that file.


    No, there is NO WAY to do that. Stop wanting that.

    Some programs may stop reading when they reach some internal marker in
    the file, but many or most will always be able to see the whole thing no
    matter what you put there.
    David Harmon, Mar 11, 2007
    #8
  9. Salman wrote:
    > Hi,
    > We usually read file until we get EOF character.
    > How EOF look like? i want to put EOF character at the start of my data
    > file, so that no one can read that file use as he will get EOF at the
    > start of file.
    >
    > Tell me how can i do this?
    >
    > ive used the following program but its not working.
    >
    > -----------------------------------
    > fstream fout;
    > fout.open("a.txt");
    > char temp = EOF;
    > f<<temp;
    >


    Some systems have and EOF character, such as 0x1A for
    MS Windows & MSDOS. However, this only works for reading
    a file in text mode for this platform. EOF for binary
    mode is defined as the physical end of the file or stream.

    Better methods are to encrypt your data. Use your
    favorite search engine and look up "encryption C++".

    --
    Thomas Matthews

    C++ newsgroup welcome message:
    http://www.slack.net/~shiva/welcome.txt
    C++ Faq: http://www.parashift.com/c -faq-lite
    C Faq: http://www.eskimo.com/~scs/c-faq/top.html
    alt.comp.lang.learn.c-c++ faq:
    http://www.comeaucomputing.com/learn/faq/
    Other sites:
    http://www.josuttis.com -- C++ STL Library book
    http://www.sgi.com/tech/stl -- Standard Template Library
    Thomas Matthews, Mar 11, 2007
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SL_McManus

    A question about EOF

    SL_McManus, Dec 3, 2003, in forum: Perl
    Replies:
    1
    Views:
    467
    Jim Gibson
    Dec 4, 2003
  2. Sacha Korell
    Replies:
    2
    Views:
    14,854
    Mattias Sjögren
    Sep 6, 2003
  3. Kobu
    Replies:
    10
    Views:
    604
    Keith Thompson
    Mar 4, 2005
  4. SpreadTooThin

    ifstream eof not reporting eof?

    SpreadTooThin, Jun 13, 2007, in forum: C++
    Replies:
    10
    Views:
    675
    James Kanze
    Jun 15, 2007
  5. Jan Burse
    Replies:
    67
    Views:
    1,026
    Jan Burse
    Mar 14, 2012
Loading...

Share This Page