if function is declared as static in one source file, if I
would like to use the same function in some other source
file...is it possible....how ?
Answer Posted / vadivel t
It is possible. follow the guidelines below.
1.create a .c file called mai.c. and Its content is,
#include<stdio.h>
#include "Header.h"
static func(void);
main()
{
func();
printf("\n");
func1();
getch();
}
static func(void)
{
printf("In static fucntion");
}
2.create another file called test.c. And its content is
#include "Header.h"
func1()
{
func();
}
func()
{
printf("In normal function \n");
}
3.have a .h file called Header.h and its content is,
func1();
func();
Now main.c has a function with static key word(ie., static
func()). And its prototype and definition is available in
the same file and the same function name without static is
exist in the test.c and its prototype is there in the
Header.h
When u run the program and control hits func() in main.c it
will call the static function in the same file.
When control hits next line ie., func1() it will call the
fuction func(), which is there in the test.c file(and also
there in main.c with static key word).
Now the output will be,
In static fucntion
In normal function
| Is This Answer Correct ? | 9 Yes | 41 No |
Post New Answer View All Answers
How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same
What is chain pointer in c?
What does malloc () calloc () realloc () free () do?
What is wrong with this program statement? void = 10;
What are the benefits of organizational structure?
What is #define size in c?
Is there any demerits of using pointer?
What is && in c programming?
Do pointers need to be initialized?
What is c programing language?
What is use of integral promotions in c?
How are strings stored in c?
what are non standard function in c
a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion
Can a variable be both static and volatile in c?