-1

Can I call a function below the function? because I get an error of implicit declaration of function
Like in example below I have function() below functionpp() but in functionpp() I called function(). I have a code where I need to call each functions.

i.e.

function()
{
functionpp();
//some code
}

functionpp()
{
//some code
function();
}
Gastrodia
  • 1
  • 3
  • You need to declare the function (or function signature) before you call it (or include a header that declares it) – byxor Feb 03 '22 at 10:55
  • @byxor how do i include a header that declares it? – Gastrodia Feb 03 '22 at 10:56
  • 4
    Stack Overflow is not a replacement for basic research and reading of existing C references. This is covered in any good C book or tutorial and a search of the warning message will bring up many relevant results. – kaylum Feb 03 '22 at 10:58
  • Write the function prototype/signature in a separate file (usually with `.h` extension), then write `#include "myfile.h"` at the top of whatever file you want to use it in – byxor Feb 03 '22 at 10:58

1 Answers1

0

No, you have to declare your function before you can use it. Otherwise the compile does not know your function. One way to archieve what you wanted to do could be:

void foo(void);

void bar(void) 
{
   foo();
}

void foo()
{

}