Let us say i have
#include<stdio.h>
#include"File2.c"
void test(void)
{
sum(1,2);
}
int main(void)
{
int sum(int a,int b);
test();
sum(10,20);
return 0;
}
int sum(int x,int y)
{
printf("\nThe Sum is %d",x+y);
}
Now as far as my understanding goes test() calling sum() should give a Compile-Time Error since i have made/declared sum() local to main, which i am not getting, and the program is running fine without any errors.
My main purpose is to define sum in File2.c and make it local to main() so that no other function has visibility to this function sum().
Where am i going wrong?
Mark the function as static (this makes it local to the current translation unit).
For the love of god, do not include .c files! (read me)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With