![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| System time comparison to fixed defined time | zainravi | Shell Programming and Scripting | 2 | 03-22-2009 01:13 PM |
| Convert Epoch Time to Standard Date and Time & Vice Versa | DrivesMeCrazy | Shell Programming and Scripting | 5 | 02-07-2009 01:40 AM |
| Need to get 4 Hrs back time and compare with successive time | maanik85 | UNIX for Dummies Questions & Answers | 2 | 07-15-2008 08:48 AM |
| Linux Going Big Time and Prime Time Against Windows, UNIX (WSJ) (Addict 3D) | iBot | UNIX and Linux RSS News | 0 | 06-21-2007 04:10 PM |
| How To Provide Time Sync Using Nts-150 Time Server On Unix Network? | pesty | UNIX for Advanced & Expert Users | 2 | 03-22-2007 02:20 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
How to log time in C/C++
Hi,
Actually I want to create a log file in c, which should log the details in to log file. Here am facing one problem..like if I am doing loging am not able to log the exact time..Its printing the same time..Can anybody help me out on this..?? Sample code: =========== #include <stdio.h> #include <time.h> #include<stdlib.h> struct tm *ptr; time_t lt; FILE * pFile = fopen("myfile.txt","a"); int main () { int n; char name [100]; lt = time(NULL); fprintf(pFile,"\n==========starting===========\n"); for (n=0 ; n<2 ; n++) { puts ("please, enter a name: "); gets (name); printf("%s %d",__FILE__,__LINE__); fprintf (pFile,"\nName %d [%-10.10s] : %s : Line %d: %s\n",n,name,__FILE__,__LINE__,asctime(localtime(<))); } fprintf(pFile,"Hello : %s : Line %d: %s\n",__FILE__,__LINE__,asctime(localtime(<))); fprintf(pFile,"Error : %s : Line %d: %s\n",__FILE__,__LINE__,asctime(localtime(<))); fprintf(pFile,"=======COMPLETED========"); return 0; } Here I could print the log time..but always its same..I need it in a sequence order.. Could you please help me out on this..? Thanks in advance..! |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|