[Dev-C++] A problem about the pointer.
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <per...@ya...> - 2004-06-15 01:37:58
|
I have write a very simple program to test the pointer.The program is list belove:
/* **************************************** */
#include <stdio.h>
int *p;
void Func(void)
{
int number;
number = 11;
p = &number;
}
main()
{
Func();
printf("*p = %d\n", *p);
}
/* ***************************** */
The result is :
*p = 11
The variable "number" is local variable that will be destoryed after leave the Func( ) and the pointer "p" is pointer to it.Although p is global variable,it pointer to a deleted area. To my way of thinking,*p should be a ignorance value.Is my understand wrong?
Thanks,
Bruce.J
---------------------------------
Do You Yahoo!?
嫌邮箱太小?雅虎电邮自助扩容! |