About functions

B

beginers of c

What's the actual use of declaring any function globally
for eg
#include<stdio.h>
int add() //function
void main()
{
}
 
J

James Kuyper

beginers said:
What's the actual use of declaring any function globally
for eg
#include<stdio.h>
int add() //function
void main()
{
}

So you only have to declare it once, rather than separately in each
subroutine. If you only have one subroutine in the file (as above), then
it doesn't make much difference.
 
B

Barry Schwarz

What's the actual use of declaring any function globally
for eg
#include<stdio.h>
int add() //function

If you don't include the parameter types, not much. If you include
the parameter types (and add the required ;), this becomes a prototype
and the compiler can syntax-check your function calls.
void main()

And you might as well define main properly if you intend to ask for
help here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top