943,942 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1258
  • C++ RSS
Sep 26th, 2007
0

User Defined function on time

Expand Post »
hi , i'm writing a user define function for time i don't know is it correct.. need help

here are my code
C++ Syntax (Toggle Plain Text)
  1.  
  2. void Time(char buffer[256], time_t curtime , struct tm *loctime)
  3. {
  4. curtime = time (NULL);
  5.  
  6. loctime = localtime (&curtime);
  7.  
  8. fputs (asctime (loctime), stdout);
  9.  
  10. strftime (buffer, 256, "Today is %A, %B %d.\n", loctime);
  11. fputs (buffer, stdout);
  12. strftime (buffer, 256, "The time is %I:%M %p.\n", loctime);
  13. fputs (buffer, stdout);
  14.  
  15. return 0;
  16. }
Last edited by Ancient Dragon; Sep 26th, 2007 at 9:06 am. Reason: add code tags
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
de_ghost is offline Offline
1 posts
since Sep 2007
Sep 26th, 2007
0

Re: User Defined function on time

>> i don't know is it correct
Compile and test it and find out if its correct or not.


1. There is no need for the second and third parameters to that function and possibly not even the first parameter. You can make all those parameters local to that function because the calling function will not be able to see them.

2. Delete the return 0 last line because void functions to not return anything.
Last edited by Ancient Dragon; Sep 26th, 2007 at 9:10 am.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,953 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Some math and MFC
Next Thread in C++ Forum Timeline: Need to send output to notepad





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC