Can anyone tell me if I can do the following:

Define a global variable in one cpp/c file (call it file1.c)
Then have it as an extern in a second file (call it file2.c),
but don't allow it to be changed from this file.
for example:

/****file1.c********/
double NiceVar;

void function()
{
NiceVar = 100; // I can set the value in file1.c easily.
}
/****************/

/****file2.c********/
extern double NiceVar;

void main()
{
NiceVar = 1000; // This shouldn't work.
printf( "%f", NiceVar ) // But this should return 100
}
/****************/


You'll have to excuse the basic explanation, but I am still a beginner!