View Single Post
Old 08-26-2014, 01:09 AM   #1
REACTOR
Question the trends!
 
REACTOR's Avatar
 
Join Date: Apr 2011
Location: Malaysia
Posts: 1,162
Default Problem: Functions In C

I am regaining confidence and so far, know the ins and outs of a simple program, my next assignment is to write a function, and so I did by my father's words, but I don't have a clue what to do, the compiler keeps on throwing at me, unknown reference errors.
Here is my code for the main function at hand: The compiler throws no errors about it when I compile.

fmin.c
Code:
/*
 * Author: Sebastian
 * Date: 26/AUG/2014
 * 
 * Input: An array of integers, the size of an array can only be from 1-100. 
 * Output: The smallest number found from the array.
 * Description: This functions assigns a given array of values to a specific table, it then  *goes through a loop which
 * determines which value out of all the other values, is the smallest.
 * 
 */

int fminimum ( int table[] )
{

    int min = 0;
    int tableindex = 0;
    
    min = table[tableindex];
    
    for ( tableindex = 1; table[tableindex] != -1; tableindex++ )
    {
        if ( table[tableindex] < min )
        min = table[tableindex];
    };
    
    return (min);

}
And here is my header file code:

fmin.h
Code:
/*
 * Author: Sebastian
 * Date: 26/AUG/2014
 * 
 * Input: An array of integers, the size of an array can only be from 1-100. 
 * Output: The smallest number found from the array.
 * Description: This functions assigns a given array of values to a specific variable, table, it then goes through a loop which
 * determines which value out of all the other values, is the smallest.
 * 
 */

int fminimum ( int table[] );
When I declare my header file at the top of the program I am adding my new function to, I use "" not <>, so it's not the case with that, but whenever I say build, it gives a compilation failure error message, UNKNOWN REFERENCE TO FMINIMUM.

I don't know what I am doing wrong. I checked it up on the internet, but none of those guys give a clear explanation of what is happening.

Edit: And also, if I try to compile fmin.c, it will give an error of the same kind but telling me there is an undefined reference to main.

Last edited by REACTOR; 08-26-2014 at 01:31 AM.
REACTOR is offline   Reply With Quote