Thread: Need help with a function of a program.

  1. #1
    Registered User
    Join Date
    Jun 2013
    Posts
    2

    Need help with a function of a program.

    Code:
    GetBorders(&xmin, &xmax, &ymin, &ymax);
    Code:
    void GetBorders(double *xmin, double *xmax, double *ymin, double *ymax)
    {
       *xmin = 0 - RADIUS - 7;
       *ymin = 0 - RADIUS - 7;
       *xmax = RADIUS + 7;
       *ymax = RADIUS + 7;
    }
    RADIUS is defined as 3.0 and the values read into GetBorders are doubles.

    This code is giving me the following errors:
    moredarts.c:43: warning: conflicting types for 'GetBorders'
    moredarts.c:27: warning: previous implicit declaration of 'GetBorders' was here

    any suggestions as to how to fix this?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Yes, you prototype the function before you try to use it.

    Say
    void GetBorders(double *xmin, double *xmax, double *ymin, double *ymax);
    somewhere before line 27.

    Without a prototype / definition in scope, at line 27, the compiler synthesised this for you.
    int GetBorders();
    which obviously conflicts with the later definition.
    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.

  3. #3
    Registered User
    Join Date
    Jun 2013
    Posts
    2
    Thank you!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Cannot get program to go to function
    By psppb in forum C Programming
    Replies: 3
    Last Post: 07-18-2012, 12:23 AM
  2. c program using if function !!!!!!
    By ravikanyal11 in forum C Programming
    Replies: 9
    Last Post: 10-24-2011, 09:06 AM
  3. Function Program
    By cutie0507 in forum C++ Programming
    Replies: 6
    Last Post: 11-24-2009, 11:38 PM
  4. Help please with function program.
    By gator6688 in forum C++ Programming
    Replies: 12
    Last Post: 10-01-2007, 11:40 AM
  5. function program help
    By katie2 in forum C++ Programming
    Replies: 4
    Last Post: 10-30-2006, 08:27 PM