C Board  

Go Back   C Board > General Programming Boards > C# Programming

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 03-29-2005, 10:05 AM   #1
Registered User
 
Join Date: Mar 2005
Posts: 11
Pointers...Problem still exists

Hi everyone, I need help with the pointers. Here's my question:

Using a pointer, write a function named time() that accepts an integer number of seconds and the addresses of three variables named hours, min, nad sec. The function is to convert the passed number of seconds into an equivalent number of hours, minutes, and seconds and directly alter the vlaue of respective variables using the passed addresses.

To test, run the program using 10,000 seconds.

This is what I have done so far, but its not working...


Code:
:
#include<stdio.h>

int time(int time, int *hours, int *mins, int *secs);

int main()

{

int time, secs, mins, hours;

printf("Enter the number of time in seconds: ");
scanf("%d", &time);
printf("\nHours: ", &hours);
printf("\nMinutes: ", &mins);
printf("\nSeconds: ", &secs);

return 0;
}

int time (int time, int *hours, int *mins, int *secs)
{

	*hours = time / 3600;
	time %= 3600;

	*mins = time / 60;
	time %= 60;

	*secs = time;


}
Mahesh is offline  
Old 03-29-2005, 11:20 AM   #2
and the hat of Jobseeking
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,710
Spamming your C questions on the C# board won't help your cause.
Pointers...Problem still exists
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.

Salem is offline  
Closed Thread

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with file handling (pointers) hmk C Programming 5 09-19-2008 10:03 AM
Problem with pointers kotoko C Programming 3 06-12-2008 05:17 AM
Returning pointer to array of pointers problem jimzy C Programming 15 11-11-2006 06:38 AM
pointers problem toshog C Programming 4 09-11-2006 03:17 AM
Problem writing swap using pointers joshdick C++ Programming 1 02-29-2004 10:06 PM


All times are GMT -6. The time now is 09:15 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22