»
 

Go Back   ResellerRatings Store Ratings > ResellerRatings Forums > Tech Support

Reply
 
LinkBack Thread Tools Display Modes
Old 12-26-2003, 08:01 AM   #1 (permalink)
Registered User
 
Join Date: Dec 2003
Posts: 1
Ahsan Ullah Burk is on a distinguished road
Kids extremely interestingQuestion about Array

Hi Every oNe!!!

i have got a strange question its about the Pointers.
well before asking u the question can u suggest what should be the output of the following cod !!! Interesting isnt it...........
it out puts what i want i.e. the value of the varaible and the address of the variable but why why is it doing so when i am assinging its value to a pointer and that is never assinged to a variable ( a ) which is used to display its value . what i think of this program is that it will print the Garbage Value of the variable a and the memory address of the Pointer P;
Ur Help Needed !!!!!!

??????????????? ????????????? ????????


#include <stdlib.h>
#include <iostream.h>
#include <conio.h>

void main(void)
{
int *p;
int *c;
int a;

p=&a;
cout<<"Enter a Number\t";
cin>>*p;
cout<<"Value of the vairable = "<<a<<endl;
cout<<"Memory Address of the Variable = "<<p<<endl;
cout<<endl;

system("PAUSE");
}
[COLOR=blue]

Ahsan Ullah Burk is offline   Reply With Quote
Old 01-22-2004, 01:14 AM   #2 (permalink)
Registered User
 
Join Date: Jan 2004
Location: Michigan
Posts: 6
pkanaby is on a distinguished road
I don't quite understand your question. The pointer "p" is set to the address of "a", then you input "a" by dereferencing the pointer with the *. Then you simply print the value of "a" and then the address of "a". I'm not sure, but I think you may have looked over the part where you dereference "p" to use it as "a" for the input statement. If not, then I have misinterpreted what you were asking. Worth a shot.

-Phil (pkanaby@comcast.net)
pkanaby is offline   Reply With Quote
Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 On


Most Active Discussions

Recent Discussions

All times are GMT -6. The time now is 11:44 PM.