User Defined function on time

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2007
Posts: 1
Reputation: de_ghost is an unknown quantity at this point 
Solved Threads: 0
de_ghost de_ghost is offline Offline
Newbie Poster

User Defined function on time

 
0
  #1
Sep 26th, 2007
hi , i'm writing a user define function for time i don't know is it correct.. need help

here are my code
  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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,374
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1466
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: User Defined function on time

 
0
  #2
Sep 26th, 2007
>> 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.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC