file modification code

Status
Not open for further replies.

smith_kang

Member level 5
Joined
Jan 22, 2005
Messages
89
Helped
4
Reputation
8
Reaction score
3
Trophy points
1,288
Activity points
861
hi all
I want to write a code in C such that it will erase the content of a file modified 24 hr before.
lets say i wrote file yesterday and if today i open this file it should be blank.file should be there contents should erase.

thanks in advance
 

hi,
can u clarify the exact OS on which u want this code ??
 

erase the whole file and create it again
 

you could open the file in write only mode i.e. "w" mode

for example

void main()
{
FILE *fp;

fp=fopen("c:\\mysoftwr\\trial.txt","w");
}

Added after 2 minutes:

pls note that while writing the filename the double back-slash is necessary
 

U can acess the file flags such as the date and time and attributes(hidden/readonly/system) from the C functions itself, I think ur purpose is solved
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…