need help on this program linker error !!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • angelcd
    New Member
    • Dec 2006
    • 15

    need help on this program linker error !!

    hi guys,

    i have this program but it wont compile on DEV C++, it compiles on Borland actually, my compiler say:

    [linker error] undefine reference hms (long, long*,long*,lon g)
    ld return 1 exit status

    can someone tell me what is this all about?

    heres my code:

    #include <stdio.h>
    #include<math.h >

    void hms(long int, long int*, long int*, long int*);


    int main()

    {
    long int time;
    long int hr, mn, sc;
    time = hr = mn = sc = 0;
    printf("Enter the total number of seconds: ");
    scanf("%ld", &time);
    hms(time, &hr, &mn, &sc);
    printf("\n%ld seconds are %ld hours, %d minutes and %ld seconds",time, hr, mn, sc);
    return 0;
    }

    void hms(long int time, int *hr, long int *mn, long int *sc)

    {
    *hr = time / 3600;
    *mn = (time - (*hr * 3600)) / 60;
    *sc = (time - (*hr * 3600) - (*mn * 60));
    }
    Last edited by angelcd; Jan 9 '07, 03:29 AM. Reason: mistake
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    your hms() function prototype is
    Code:
    void hms(long int, long int*, long int*, long int*);
    second parameter is long int*

    but in the function definition the function header is
    Code:
    void hms(long int time, int *hr, long int *mn, long int *sc)
    second parameter is int*

    change the definition to match the prototype
    Code:
    void hms(long int time, long int *hr, long int *mn, long int *sc)

    Comment

    Working...