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

if function is declared as static in one source file, if I would like to use the same function in s..

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

if function is declared as static in one source file, if I would like to use the same function in s..

Answer / vadivel t

It is possible. follow the guidelines below.

1.create a .c file called mai.c. and Its content is,

#include "Header.h"

static func(void);

static func(void)
printf("In static fucntion");

2.create another file called test.c. And its content is

#include "Header.h"

printf("In normal function \n");

3.have a .h file called Header.h and its content is,


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

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

More C Interview Questions

Write a C program that reads a series of strings and prints only those ending in "ed"

2 Answers   Accenture,

int main() { int i=-1,j=-1;k=0,l=2,m; m=i++&&j++&&k++||l++; printf("%d%d%d%d%d",i,j,k,l,m); }

3 Answers   HCL,

What is the output of the following program #include<stdio.h> main() { int i=0; fork(); printf("%d",i++); fork(); printf("%d",i++); fork(); wait(); }

8 Answers   Adobe, ADITI,

main() { enum{red,green,blue=6,white}; pf("%d%d%d%d", red,green,blue,white); return 0; } a)0 1 6 2 b)0 1 6 7 c)Compilation error d)None of the above

6 Answers  

write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list

0 Answers   Persistent,

1.)how to find d most repeated word in a string? string ="how do you do"?? output should be do

1 Answers   Nagarro, AAS, Vuram,

write a program to swap bits in a character and return the value prototype of function char fun (char a, charb flag c) where fun returns a char, char a is a the value char b is the bit to be changed and flag c is the bit value for eg: x=fun(45,7,0) since 45 is 0010 0101 and ow x should contain the value 65 (0110 0101)

1 Answers   Bosch, College School Exams Tests,

who is the editor of 'pokemon'?

1 Answers  

Tell me a C program to display the following Output? 1 1 1 1 1 2 2 2 2 3 3 3 4 4 5

3 Answers  

in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.

0 Answers   TCS,

The purpose of this exercise is to benchmark file writing and reading speed. This exercise is divided into two parts. a). Write a file character by character such that the total file size becomes approximately >10K. After writing close the file handler, open a new stream and read the file character by character. Record both times. Execute this exercise at least 4 times b). Create a buffer capable of storing 100 characters. Now after generating the characters, first store them in the buffer. Once the buffer is filled up, store all the elements in the file. Repeat the process until the total file size becomes approximately >10K.While reading read a while line, store it in buffer and once buffer gets filled up, display the whole buffer. Repeat the exercise at least 4 times with different size of buffer (50, 100, 150 …). Records the times. c). Do an analysis of the differences in times and submit it in class.

0 Answers  

What does extern mean in a function declaration?

4 Answers