Consider the following example
void tester(unsigned char *);
void main()
{
unsigned int test,y;
tester(&test);
y=test
}
void tester( unsigned char *x)
{
*x=36;
}
What will be the value of y now?
whether address of test will be removed from the subroutine void tester once its exits!!
Please clarify!
解決済! 解決策の投稿を見る。
Not quite true! y and test are of type unsigned int (16 bits) while the argument to the tester-routine is a pointer to an unsigned char. The compiler will probably give you a warning, but will compile and the program will run. Since the Freescale-controllers are big-endian, the tester-routine will write the number 36 to the most significant byte of the test-integer, giving a result of 0x2400 = 9216.
/Sten
Value of y will be 36.
the address of variable test is taken as the value x is pointing to. so the address of variable will hold value 36.
as y is assigned to test, y becomes 36.
I hope it helps.
-AH
Not quite true! y and test are of type unsigned int (16 bits) while the argument to the tester-routine is a pointer to an unsigned char. The compiler will probably give you a warning, but will compile and the program will run. Since the Freescale-controllers are big-endian, the tester-routine will write the number 36 to the most significant byte of the test-integer, giving a result of 0x2400 = 9216.
/Sten