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 can I write data files which can be read on other machines with different word size, byte order, or floating point formats?
What does. int *x[](); means ?
What is signed and unsigned?
about c language
What is the c language function prototype?
Tell me when would you use a pointer to a function?
What is the meaning of typedef struct in c?
What does != Mean in c?
Explain continue keyword in c
Once I have used freopen, how can I get the original stdout (or stdin) back?
What is the size of a union variable?
What is string length in c?
What are pointers really good for, anyway?
Explain enumerated types in c language?
Hai what is the different types of versions and their differences