How actually to use extern

suppose in file 1 i write code..(test_new.c)

#include <stdio.h>

 #include<math.h>

 int interest_rate =5;
int main()
{
   int test = 0;
   int t=5;
  // cout<<ceil(log2(5));//
//  cout<<pow(2,ceil(log2(5)));

 getchar();
   return 0;
}

In file 2 i write

#include<stdio.h>
#include"test_new.c"
extern int interest_rate;
void fun()
{
interest_rate=6;
}

it works..
now if i make interest_rate as static in c..it also wokrs in file 2..but it
should not...and if i remove the declaration of interest from file 2 it
also works...all this happening becoz i #included test_new.c(file1) in
file2....so i definition comes in a...plz tell how to tell fille 2 to refer
file 1...as by #inlcuded resultsare not as accepted...itz full code coming
in file a...i want that

global variable is accessible in file 2 but for static it shows that itz an
undefined reference....plz provide me code snippet..

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to