Thread: error calling function

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    30

    error calling function

    O.K. I have a program that finds the solution to addding, subtracting, dividing or multiplying a fractions. My problem occurs when I try to find the Greatest common factor. I have the Greatest common factor funtion declared in the class as:
    int dogcf(int, int)
    In the int main I have it as:
    dogcf(int, int);
    And in the header for the function i have it as:
    int dogcf(int num, int den);

    num and den are the numerator and denominator of the problem. When I try to compile it I get an error message that reaads as follows:
    fractions3.cpp: In function `int main()':
    fractions3.cpp:37: parse error before `,'

    What do I have to do to the calling of it in int main() to fix this problem? If anyone knows I would appreciate some help.
    Thanks. Kyle

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Code:
    int main()
    {
       int num, den;
       cout << "Enter numerator and demoninator:";
       cin >> num >> den;
       cout << "Greatest common factor:" << dogcf(num, den) << endl;
       return 0;
    }
    or you could just say:

    int gcf;
    gcf = dogcf(3, 5);
    Last edited by swoopy; 11-29-2001 at 02:18 PM.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Where's that spell checker?

    cout << "Enter numerator and denominator:";

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    30
    Thanks for the help. It did not work but the attempt was appreciated. I just turned in the assignment by writing gcf right in the int main. If anyone has any ideas on what was wrong i would appreciate it since finals are next week and there may be something like that on it.
    Thanks again, Kyle

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM