J
junky_fellow
Guys,
Consider the following two files, files test.c and test1.c
Contents of test1.c are as follows:
---------------------------------------------------
int arr[] = { 0x100, 0x200 };
int main(void)
{
printf("arr[0]=%x arr[1]=%x\n", arr[0], arr[1]);
func();
}
Contents of test1.c
------------------------------
extern int *arr;
func()
{
printf("arr[0]=%x arr[1]=%x\n", arr[0], arr[1]);
}
The 2 files are compiled without any error, but when I run the
executable generated, it crashes with segmentation fault.
Can someone please explain what is the reason for crash ?
Consider the following two files, files test.c and test1.c
Contents of test1.c are as follows:
---------------------------------------------------
int arr[] = { 0x100, 0x200 };
int main(void)
{
printf("arr[0]=%x arr[1]=%x\n", arr[0], arr[1]);
func();
}
Contents of test1.c
------------------------------
extern int *arr;
func()
{
printf("arr[0]=%x arr[1]=%x\n", arr[0], arr[1]);
}
The 2 files are compiled without any error, but when I run the
executable generated, it crashes with segmentation fault.
Can someone please explain what is the reason for crash ?