Thread: calling functions

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    4

    calling functions

    Hello, I've been having a problem calling functions in C. I've tried just about everything I could think about to make this work. If anybody can help give me an understanding of this I would really appreciate it.

    the code:


    #include <stdio.h>
    main ()
    {
    int find_max(int, int);
    int a, b, total;

    a=32;
    b=45;
    total = find_max(a, b);
    printf("the max of the two numbers are %d\n", total);
    }

    Pretty simple code for finding the maximum number within the program, but this is the compling error I get:


    nicholas@nicholas-laptop:~/CProgramming$ gcc functions2.c -o functions2
    /tmp/ccfYe8Qe.o: In function `main':
    functions2.c.text+0x29): undefined reference to `find_max'
    collect2: ld returned 1 exit status

    Thanks for any help in advance.

  2. #2
    Registered User
    Join Date
    Dec 2010
    Posts
    20
    Code:
    #include <stdio.h>
    main ()
    {
    int find_max(int, int);
    int a, b, total;
    
    a=32;
    b=45;
    total = find_max(a, b);
    printf("the max of the two numbers are %d\n", total);
    }
    
    find_max(x,y)
    
    {
    
    if(x>y) return x;
    else return y;
    
    }

  3. #3
    Registered User krishnapollu's Avatar
    Join Date
    Dec 2010
    Location
    KERALA
    Posts
    29
    u cant call a function without defining it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 11-04-2010, 10:23 AM
  2. Calling functions from functions
    By droseman in forum C Programming
    Replies: 4
    Last Post: 01-21-2010, 06:33 AM
  3. Functions calling other functions.
    By kbro3 in forum C++ Programming
    Replies: 2
    Last Post: 12-27-2009, 12:10 AM
  4. Problems calling functions
    By barryr in forum C Programming
    Replies: 12
    Last Post: 12-03-2009, 08:44 AM
  5. Replies: 12
    Last Post: 04-12-2009, 05:49 PM