guys, i have a problem that i cant name folders after the date we are in.
in the below code: GPpsTime has been calculated and updates regulary. and "day" is the current number of day of the year. the file creation bit works perfectly as i have tried it elsewhere.
my attempt below doesnt work because i might be acting silly and assuming thatwill automatically change the name of the new folder.Code:&day
can anyone help me?
my attempt
Code:#include <stdio.h> #include <iostream> #include <stdlib.h> #include <time.h> #include <windows.h> //****************************************************************** //Creates a new directory everytime the clock ticks over to 00:00:00. //Directory is given the name of the current day //uses names "GpsTime" and "Day" from time conversion routine //Creates 24 new files within directory with hour names //Continues onto writing routine //****************************************************************** #define MAX 24 int main() { int clock, hour, last_hour = -1; while(1) { unsigned int hour = (GpsTime / 3600) % 24; //current hour we are in if (hour == 0 && last_hour == 11) //when hour ticks over to 0, create new directory { CreateDirectory("c:\\temp\\day", NULL); //creates a folder with current day as name printf("Directory created\n"); } last_hour = hour; } SetCurrentDirectory("c:\\temp\\&day"); //sets current directory to day for creation of files { char buf[BUFSIZ]; FILE *fp; int i; for (i=0; i<MAX; i++) { sprintf(buf, "%d h.txt", i+1); if ((fp = fopen(buf, "a+")) == NULL) { fprintf(stderr, "\n\n\n\n\nCan't open %s!\n\n\n\n\n", buf); continue; } } printf("\n\n\n\n\n\nNew directory and files created, Program will now continue\n\n\n\n");; } }



LinkBack URL
About LinkBacks
guys, i have a problem that i cant name folders after the date we are in.


