954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

User Defined function on time

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

here are my code

void Time(char buffer[256],   time_t curtime , struct tm *loctime)
	  {
		 curtime = time (NULL);

		 loctime = localtime (&curtime);

		 fputs (asctime (loctime), stdout);

		 strftime (buffer, 256, "Today is %A, %B %d.\n", loctime);
		 fputs (buffer, stdout);
		 strftime (buffer, 256, "The time is %I:%M %p.\n", loctime);
		 fputs (buffer, stdout);

		 return 0;
	  }
de_ghost
Newbie Poster
1 post since Sep 2007
Reputation Points: 10
Solved Threads: 0
 

>> 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.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You