I want to create a text file with the name as SYSTEM DATE...
for example---28/04/2008:9:11:50.txt
The File name should be allocated dynamically.

Can you provide the c code for this?

Plese help me.

You can not use / characters in file name. The best format is YYYYMMDD (Year Month Day)format because such file names can be easily sorted sorrecty.

To get the system time use the localtime() function found in time.h. That will return a structure that you can use either sprintf() or strftime() to format the time into a character array.

Thanks for ur reply.I used strftime to get the date.
I am not getting how to open a text file with this and i need to append the data from mouse into this file

This is my code:

#include <time.h>
int main()
char s[30];
int fp;
size_t i;
struct tm tim;
time_t now;
now = time(NULL);
tim = *(localtime(&now));
i = strftime(s,30,"%b %d, %Y; %H:%M:%S\n",&tim);

Does s contain the file name you want to open? If so, use it in your fopen() statement.

s contains Dec 22, 2010; 18:45:21.txt
I tried fopen.but the file is not opening
i = strftime(s,30,"%b %d, %Y; %H:%M:%S.txt",&tim);

i can't able to see the file Dec 22, 2010; 18:45:21.txt in the directory when i type ls.

you formatted the fopen() incorrectly. Do not put s in quotes fp = fopen(s,"w");

thankyou very much its working.