Geeks Talk

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.

regarding bug.......

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 ...

Go Back   Geeks Talk > Software Development > C and C++
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 09-30-2009
Junior Member
 
Join Date: Sep 2009
Location: gurgaon
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
eshivaprasad is on a distinguished road
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...
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-08-2009
Junior Member
 
Join Date: Mar 2009
Location: COIMBATORE
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
sumitsolution is on a distinguished road
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
Reply With Quote
Reply

  Geeks Talk > Software Development > C and C++

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -4. The time now is 11:29 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved