Return to Snippet

Revision: 30818
at August 23, 2010 10:05 by khajavi


Initial Code
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
void writer(FILE *fout, FILE *fin); 
int main (void) {
	FILE *shab, *rooz, *vnstat;

	char shabane[] = ".shabane";
	shab = fopen(shabane, "r");

	char roozane[] = ".roozane";
	rooz = fopen(roozane, "r");

	char vnstatrc[] = ".vnstatrc";
	vnstat = fopen(vnstatrc, "w");

	time_t now_time;
	time (&now_time);

	struct tm *now;
	now = localtime(&now_time);
	
	int hour;
	hour = now->tm_hour;

	if ( hour >= 3 & hour <= 7 ) {
		writer(vnstat, shab);
	} else {
		write(vnstat, rooz);
	}

	
	fclose(vnstat);
	fclose(shab);
	fclose(rooz);

	return 0;
}	

void writer(FILE *fout, FILE *fin) {
	int c;
	while((c = fgetc(fin)) != EOF) {
		fputc(c, fout);
	}
}

Initial URL


Initial Description


Initial Title
Exchange two file by time

Initial Tags
c

Initial Language
C