News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Problem Defining Functions with minGW Compiler and Codeblocks 13.12

Started by mephisto, June 01, 2014, 02:33:44 PM

Previous topic - Next topic

mephisto

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. 

oBFusCATed

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!
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

mephisto

Thought it might have been me just wasn't sure if it was something Ihad done during setup thats why I posted here. Thanks