EOF

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Salman

    #1

    EOF

    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.tx t");
    char temp = EOF;
    f<<temp;

  • John Harrison

    #2
    Re: EOF

    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.tx t");
    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

    Comment

    • Salman

      #3
      Re: EOF

      On Mar 11, 1:36 pm, John Harrison <john_androni.. .@hotmail.comwr ote:
      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.tx t");
      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???

      Comment

      • John Harrison

        #4
        Re: EOF

        Salman wrote:
        On Mar 11, 1:36 pm, John Harrison <john_androni.. .@hotmail.comwr ote:
        >
        >>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_lengt h_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

        Comment

        • Salman

          #5
          Re: EOF

          On Mar 11, 2:04 pm, John Harrison <john_androni.. .@hotmail.comwr ote:
          Salman wrote:
          On Mar 11, 1:36 pm, John Harrison <john_androni.. .@hotmail.comwr ote:
          >
          >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_lengt h_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?

          Comment

          • Sheth Raxit

            #6
            Re: EOF

            On Mar 11, 1:32 pm, "Salman" <salman0...@gma il.comwrote:
            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.tx t");
            char temp = EOF;
            f<<temp;
            --Raxit

            Comment

            • John Harrison

              #7
              Re: EOF

              Salman wrote:
              On Mar 11, 2:04 pm, John Harrison <john_androni.. .@hotmail.comwr ote:
              >
              >>Salman wrote:
              >>
              >>>On Mar 11, 1:36 pm, John Harrison <john_androni.. .@hotmail.comwr ote:
              >>
              >>>>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_lengt h_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.program mer.win32

              john

              Comment

              • David Harmon

                #8
                Re: EOF

                On 11 Mar 2007 01:28:46 -0800 in comp.lang.c++, "Salman"
                <salman0250@gma il.comwrote,
                >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.

                Comment

                • Thomas Matthews

                  #9
                  Re: EOF

                  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.tx t");
                  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:

                  C++ Faq: http://www.parashift.com/c++-faq-lite
                  C Faq: http://www.eskimo.com/~scs/c-faq/top.html
                  alt.comp.lang.l earn.c-c++ faq:

                  Other sites:
                  http://www.josuttis.com -- C++ STL Library book
                  http://www.sgi.com/tech/stl -- Standard Template Library

                  Comment

                  Working...