Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

static function in c language

Status
Not open for further replies.

selva murugesan

Advanced Member level 4
Joined
Mar 30, 2012
Messages
116
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,298
Activity points
2,007
hello

Can any one explain me about static function in c with example?
 

I've already seen that , anything else with some depth explanation
 

I will quote you a simple example !

observe the code with and with out static,
Code:
#include<stido.h>
void foo(void)
{
    // int a = 10;
    static int a = 10;
    a++;
    printf("%d\n",a);
}

int main()
{
	foo();
    foo();
	
}
 

hi friend

I appreciate your previous work.but, my friend I would like to inform you that is static variable explanation. I knew it already. I want to know something about static function.

I have some basic idea about that function, i tried in my code blocks complier. the way of working is some what differ from what I knew the same.
 

When a function is declared as a Static function, it limits the scope of that function to the c file it is in.
So when a program is made up of several linked c files, the function can not be seen or called from the other c files.
So it is used to limit the scope of a function. (to avoid name clashes amongst other things)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top