define functions in another file
I'd like to define some functions for a program in another file as they are too long..
So, I used
PHP Code:
# include <filename.c>
but the problem comes here is that ...
The variables that I commonly used in main and this files have to be declared before I write main()..
something like:
Code:
int variable; declared above the whole code..
# include <stdio.h>
int main()
{
int a,b,c;
....
}
Is this the right way to do.
I don't know whether it totally works or not.. as I am in the middle of my code. As far as I recognized is that .. its not showing the respective error.
1. If I want to define functions in some other files and include in main..
how do I do it ?
2. Actually, my function files are not located in default location..
so, I need to mention the address too..
PHP Code:
# include </home/username/folder/filename.c>
is there any other way to do that..
what I should do .. so that I need not mention this address.
something like adding search directory to the gcc compiler for checking filess..