Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating own func 1

Status
Not open for further replies.

kreop

Technical User
Oct 9, 2005
14
JP
I have a question about creating own function and array as an argument.
Code:
#include header1.h
function1(Arg11[][3], Arg22[][2], Arg33[][4]){
Arg11[][3];
}
Code:
#include header2.h
function2(Arg1[][3], Arg2[][2], Arg3[6] ){
Arg1[][3];
[COLOR=red]function1(Arg11[][3], Arg22[][2], Arg33[][4]);[/color]
}

I dont know where to declare function1 when trying to use it in header2.h in function 2. Error cannot define function1.
My question is where and how to declare function1 to be used in function2.
 
Place both functions declarations (so called prototypes) in a header file (header.h. for example):
Code:
void f1(int a1[][3], int a2[][2], int a3[][4]);
void f2(int a1[][3], int a2[][2], int a3[6]);
Now include this file in all files where you define or use these functions, for example:
Code:
#include "header.h"

void f1(int a1[][3], int a2[][2], int a3[][4])
{
   /* Function definition here (function body) */
}

void f2(int a1[][3], int a2[][2], int a3[6])
{
   /* Function definition here (function body) */
}

int main(int argc, char* argv[])
{
 ...
  f1(x,y,z);
...
  f2(x,y,t);
}
See function header syntax: you must declare all parameter types (and returned value type too).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top