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 ?
Answers were Sorted based on User's Feedback
Answer / lakshman
using function pointer in main.c which holds address of
static function in the same file. But function pointer can
be used in other files.
| Is This Answer Correct ? | 26 Yes | 5 No |
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 |
#include<stdio.h> int main() { int a[3][3][2]= {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18}; printf("%d\n",*(*(*a+1)); return 0; } What will be the output of the above question? And how?
How many types of operators are there in c?
a memory of 20 bytes is allocated to a string declared as char *s then the following two statements are executed: s="Etrance" l=strlen(s); what is the value of l ? a.20 b.8 c.9 d.21
What is a shell structure examples?
Write a program to reverse a given number in c?
What does == mean in texting?
When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd
write a 'c' program to sum the number of integer values
Is r written in c?
#include<stdio.h> void main() { int a,b,c; a=b=c=1; c=++a || ++b && ++c; printf("%d\t%d\t%d",a,b,c); }
What is pointer & why it is used?
Explain the binary height balanced tree?