Pointers...Problem still exists

This is a discussion on Pointers...Problem still exists within the C# Programming forums, part of the General Programming Boards category; Hi everyone, I need help with the pointers. Here's my question: Using a pointer, write a function named time() that ...

  1. #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;
    
    
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,854
    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.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with file handling (pointers)
    By hmk in forum C Programming
    Replies: 5
    Last Post: 09-19-2008, 11:03 AM
  2. Problem with pointers
    By kotoko in forum C Programming
    Replies: 3
    Last Post: 06-12-2008, 06:17 AM
  3. Returning pointer to array of pointers problem
    By jimzy in forum C Programming
    Replies: 15
    Last Post: 11-11-2006, 06:38 AM
  4. pointers problem
    By toshog in forum C Programming
    Replies: 4
    Last Post: 09-11-2006, 04:17 AM
  5. Problem writing swap using pointers
    By joshdick in forum C++ Programming
    Replies: 1
    Last Post: 02-29-2004, 10:06 PM

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