EOF

S

Salman

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.
 
J

John Harrison

Salman said:
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
 
S

Salman

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???
 
J

John Harrison

Salman said:
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
 
S

Salman

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?
 
S

Sheth Raxit

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
 
J

John Harrison

Salman said:
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
 
D

David Harmon

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

Thomas Matthews

Salman said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top