![]() |
| | #1 |
| Registered User Join Date: Mar 2005
Posts: 11
| Pointers...Problem still exists 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 |
| | #2 |
| and the hat of Jobseeking 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 |
| Salem is offline |
![]() |
| Thread Tools | |
| Display Modes | |
|
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 |