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
What are register variables in c?
What would happen to X in this expression: X += 15; (assuming the value of X is 5)
Tell me what are bitwise shift operators?
What functions are in conio h?
What is the difference between test design and test case design?
What is the use of bitwise operator?
Explain how can I open a file so that other programs can update it at the same time?
What is the general form of #line preprocessor?
How to explain the final year project as a fresher please answer with sample project
What is the difference between #include
An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above
Can we assign integer value to char in c?
Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given
What is the use of the function in c?
What is signed and unsigned?