Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on regarding bug....... within the C and C++ forums, part of the Software Development category; hi..... i'm sending my code.. #include<stdio.h> void main() { int *PER,*DDR; &PER=0x0fc3; &DDR=0x0fc2; printf("%u %u",&PER,&DDR); } when i'm compiling ..i'm getting the error "Lvalue required in function main()" so please ...
|
|||||||
|
|||
|
regarding bug.......
hi.....
i'm sending my code.. #include<stdio.h> void main() { int *PER,*DDR; &PER=0x0fc3; &DDR=0x0fc2; printf("%u %u",&PER,&DDR); } when i'm compiling ..i'm getting the error "Lvalue required in function main()" so please help me hoe to debug my problem... how can i assign the address of variable directly using pointers...... please help me... |
| Sponsored Links |
|
|||
|
Re: regarding bug.......
Pointer is a variable which can store a address.....You have to do proper typecasting while assigning the addresses if you are giving it manually...Here *PER and *DDR are two pointer variable...address 0x0fce3 is assigned to PER and 0x0fce2 is assigned to DDR manually.....so it need to be typecasted as
(int *).....So PER and DDR are initialized with the given addresses which can be seen by using %u........... *********************************************** #include<stdio.h> #include<conio.h> void main(){ int *PER,*DDR; clrscr(); PER=(int *)0x0fc3; DDR=(int *)0x0fc2; printf("%u%u",PER,DDR); getch(); } Here the output will be 4035 and 4034 which comes as 4035(0x0fc3)=(16*16*15)+(16*12)+3 4035(0x0fc2)=(16*16*15)+(16*12)+2 if u want to see value present at that location use *PER,*DDR you will get some garbage value...... sumitsolution@gmail.com |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|