Code::Blocks Forums

User forums => Help => Topic started by: mephisto on June 01, 2014, 02:33:44 pm

Title: Problem Defining Functions with minGW Compiler and Codeblocks 13.12
Post by: mephisto on June 01, 2014, 02:33:44 pm
Hi Please delete this message if not appropriate to this forum.

having trouble with defining function. As you can see from the code below I have defined a power function.


#include <stdio.h>

/* simple power program*/

int power (int m, int n);

int main()
{
    int i;

    for (i=0; i < 10; ++i)

        printf ("%d %d %d \n", i, power(2,i), power(-3,i));

    return 0;
}


And yet when I build I get:



||=== Build: Debug in Learning C (compiler: GNU GCC Compiler) ===|
obj\Debug\main.o||In function `main':|
C:\Users\Tim\Documents\Source code and programs\Learning C\main.c|12|undefined reference to `power'|
C:\Users\Tim\Documents\Source code and programs\Learning C\main.c|12|undefined reference to `power'|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 4 second(s)) ===|



Running windows 7 professional service pack 1 with the latest updates.

Any help would be greatly appreciated.

Mephisto

P.S. I have included a screen dump for clarity as well. 
Title: Re: Problem Defining Functions with minGW Compiler and Codeblocks 13.12
Post by: oBFusCATed on June 01, 2014, 03:11:06 pm
you've not defined a function, just declared it... Find a text book where the difference is explained.

This is not a beginners c/c++ forum, please find a better place for asking such questions!
Title: Re: Problem Defining Functions with minGW Compiler and Codeblocks 13.12
Post by: mephisto on June 01, 2014, 04:07:13 pm
Thought it might have been me just wasn't sure if it was something Ihad done during setup thats why I posted here. Thanks