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
Why does everyone say not to use gets?
Explain output of printf("Hello World"-'A'+'B'); ?
What is nested structure in c?
Which is best linux os?
Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......
How can I list all of the predefined identifiers?
What's a good way to check for "close enough" floating-point equality?
What is pragma in c?
Explain continue keyword in c
write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);
Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a string and returns whether the string matched the regular expression.
Explain what is the advantage of a random access file?
Is it possible to initialize a variable at the time it was declared?
Subtract Two Number Without Using Subtraction Operator
Can we use visual studio for c?