Author Topic: Problem Defining Functions with minGW Compiler and Codeblocks 13.12  (Read 3248 times)

Offline mephisto

  • Single posting newcomer
  • *
  • Posts: 3
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. 
« Last Edit: June 01, 2014, 02:35:28 pm by mephisto »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Problem Defining Functions with minGW Compiler and Codeblocks 13.12
« Reply #1 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!
(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!]

Offline mephisto

  • Single posting newcomer
  • *
  • Posts: 3
Re: Problem Defining Functions with minGW Compiler and Codeblocks 13.12
« Reply #2 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