Hello everyone;
First question; how do you DELETE a file using C commands?
Second question; how can you encrypt a file so it is not readable by any means other than your program?
Printable View
Hello everyone;
First question; how do you DELETE a file using C commands?
Second question; how can you encrypt a file so it is not readable by any means other than your program?
hi if you want to delete a file using c function from hard disk, it is not possible because u need to know your os' filesystem
when u want to encrypt, that is just read the file word by word or char by char and apply any good encryption algorithm....
bye
You can delete file using C command "remove(file)".
For the encryption, this is an option:
At first you read the whole file using command "fscanf" until the EOF is found. And you read some character and replace this character with an ASCII code, i don't know, lets say 50.
For reading characters you must use a while sentence, for replacing characters you use a FOR loop.
That's all.
you could always use 'system'
system("rm -rf file");
note that this only works with unix.
you could also set up some macros and define the os at
compile-time:
#if defined UNIX
# define DEL "rm -rf"
#elif defined WINDOWS
# define DEL "del"
#elif defined MAC
# define DEF "mac's dumb, doesn't have a console" \
"and therefore no system calls"
#endif
now delete by calling system:
system(DEL "file");
you'll need stdlib.h for 'system'