On Thu, 20 Jan 2005 03:23:05 -0800, sushant wrote:
sorry for that unindented code, but its not mentioned any where that
for declaration we have to use extern keyword. i just want to declare a
local variable for that matter ...... now what??
C does not permit you to just declare local variables, all such
declarations are also definitions. Why would you want to?
Note that you can declare something like:
int main(void)
{
extern int x;
...
}
Here the scope of this declaration (which is not a definition) is local
to the block but the variable x isn't, this declaration will be "linked"
with other declarations and definition of x in the entire program that
have external linkage. E.g. if the following is in the same program, not
necessarily the same source file
int foo(void)
{
extern int x;
}
then the x in this function refers to the same object as the x in main().
There needs to be a definition for x somewhere but that has to be at file
scope, it cannot be within a function.
Lawrence