![]() |
| | #1 |
| Registered User Join Date: Jan 2009
Posts: 37
| i'm having this function: 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 |
| Ali.B is offline | |
| | #2 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| By specifying the filename you want created. If you want "../other_dir/log.txt", then say so. |
| tabstop is offline | |
| | #3 |
| Registered User Join Date: Jan 2009
Posts: 37
| Yes... ![]() Code: file = fopen("./path/log.txt","a+");
thanks for the help |
| Ali.B is offline | |
![]() |
| Tags |
| file, path, write |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A development process | Noir | C Programming | 30 | 10-28-2009 04:24 AM |
| Problems passing a file pointer to functions | smitchell | C Programming | 4 | 09-30-2008 02:29 PM |
| sequential file program | needhelpbad | C Programming | 80 | 06-08-2008 01:04 PM |
| archive format | Nor | A Brief History of Cprogramming.com | 0 | 08-05-2003 07:01 PM |
| simulate Grep command in Unix using C | laxmi | C Programming | 6 | 05-10-2002 04:10 PM |