Hi
i'm having this function:
this function creates a txt file called log.txt, in the path that the .c file exist. how can i specify a path in which the file will be created?Code:int logger(char *log_prefix,char *buffer) { printf("Logger: Logging Command...\n"); time_t now; time(&now); FILE *file; file = fopen("log.txt","a+"); // apend file (add text to a file or create a file if it does not exist. //writes the "buffer" to the txt file and current time and log prefix ( either sent or received). fprintf(file,"Time/Date:%s# Command %s = %s\n",ctime(&now), log_prefix,buffer); fclose(file); printf("Logger: Command Logged, Check log.txt for more details.\n"); return 0; }
this code



LinkBack URL
About LinkBacks



