Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?

977


What does. int *x[](); means ?

1014


What is signed and unsigned?

1014


about c language

1961


What is the c language function prototype?

1042


Tell me when would you use a pointer to a function?

1011


What is the meaning of typedef struct in c?

1004


What does != Mean in c?

987


Explain continue keyword in c

962


Once I have used freopen, how can I get the original stdout (or stdin) back?

1030


What is the size of a union variable?

999


What is string length in c?

1026


What are pointers really good for, anyway?

1013


Explain enumerated types in c language?

991


Hai what is the different types of versions and their differences

1897