Hi,
I urgently need some help on system date and time.Here's the code

#include<stdio.h>
#include<time.h>
main()
{
	time_t rawtime;
	struct tm *timeinfo;
	time(&rawtime);
	timeinfo=localtime(&rawtime);	
	
	int hour2;
	int minute2;
	int seconds2;
	char end1[5];
	int end=0;
	char diff[5];
	char start[5];
	int i=0;
	char ch[5];
	char ch1[5];
	FILE *fp2;
	FILE *fp1;
	FILE *fp3;
	
	
	
	fp2=fopen("time.txt","r");

	while(!feof(fp2))
	{
		fscanf(fp2,"%c",&ch[i]);
		start[i]=ch[i];
		printf("%c",start[i]);
		

	}
printf("\n");
	
	
	fp1=fopen("time2.txt","w");
	hour2=timeinfo->tm_hour;
	minute2=timeinfo->tm_min;
	seconds2=timeinfo->tm_sec;
	end=(hour2*3600)+(minute2*60)+seconds2;	
	fprintf(fp1,"%d",end);

	fclose(fp1);

	fp1=fopen("time2.txt","r");

	while(!feof(fp1))
	{
		fscanf(fp1,"%c",&ch1[i]);
		end1[i]=ch1[i];
printf("%c",end1[i]);
		
	}
printf("\n");
	fp3=fopen("diff.txt","w");
	
	for(i=0;i<=4;i++)
	{
        diff[i]=(int)end1[i]-(int)start[i];
	fprintf(fp3,"%c",(int)diff[i]+48);
	
	}
	
}

and here is one more

#include<stdio.h>
#include<time.h>
main()
{
	time_t rawtime;
	struct tm *timeinfo;
	time(&rawtime);
	timeinfo=localtime(&rawtime);	
	int hour1;
	int minute1;
	int seconds1;
	int start=0;
	FILE *fp1;
	fp1=fopen("time.txt","w");

	hour1=timeinfo->tm_hour;
	minute1=timeinfo->tm_min;
	seconds1=timeinfo->tm_sec;
	start=(hour1*3600)+(minute1*60)+seconds1;	
	
	//fprintf(fp1,"%d:",hour1);
	//fprintf(fp1,"%d:",minute1);
	//fprintf(fp1,"%d",seconds1);
	fprintf(fp1,"%d",start);


}

It can't be that urgent if you can't even take the time to post an actual question. Try again - and ask a question this time.

commented: Well said. +13

ok the question is i have stored a system date in file.using that time and freshly generated time iwant to find the difference if the difference is more than 1 the file containing the system date and time first should be deleted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.