Dec 25, 2012 at 9:55am UTC
Hi! I'm a new member to this forum :)
I recently started learning fstream in C++ and I have a question. How do you make it such that the user cannot edit or view the text file but the program can? Thanks!
Dec 25, 2012 at 11:29am UTC
win32 api function SetFileAttributes()
with windows or
If you don't want to pull in the windows.h header, a more lightweight solution would be to use C run-time function _chmod() . To use that function, you need to #include <io.h> .
Side note you can never make it forever un-accessable by the user as most users probably wouldn't want a bunch of files on their own computer that they couldn't edit or delete...
Dec 25, 2012 at 12:05pm UTC
They're meant for game files, I don't mind the user deleting them, I just mind them editing the text files.
Dec 25, 2012 at 12:10pm UTC
well editing is going to be unavoidable what you need to do is encrypt the data so that the user doesn't understand what they are looking at.