home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

extremely interestingQuestion about Array

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 1673
Discussions: 200,924, Posts: 2,379,113, Members: 246,290
Old December 26th, 2003, 11:01 AM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Dec 2003
Posts: 1
Question
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 January 22nd, 2004, 04:14 AM     #2 (permalink)
Junior Member
 
Join Date: Jan 2004
Location: Michigan
Posts: 6
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2859)
Obama the Muslim (14)
California Passes Anti-Flat-HDTV Le.. (39)
Is the PSU I received dead? (10)
windows vista security holes (9)
Foreign voltage (10)
HIS HD5770 graphic card question (15)
Print spooler problem (13)
Install XP pro and a Vista laptop ?.. (9)
Dept. of HS: NSA 'Helped' Develop V.. (15)
A good PSU? (10)
New Computer wont recognize XP disc (7)
Ideal cheap graph card for PC-Gamin.. (15)
EVGA 9800 gtx help with finding a g.. (8)
Recent Discussions
WIRELESS ROUTER (0)
Optical Audio A-B Switch (1)
windows vista security holes (9)
Fire in DVD (0)
radeon x850xt platinum & shader 3 (2)
The NTDVM CPU has encountered an ille.. (24)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (34)
Wireless speakers for PC? (11)
Print spooler problem (13)
Help getting around port 80 for camer.. (2)
Display shows 3x5 inch in middle of s.. (3)
monitor will not turn on at all, (1)
World's largest Monopoly Game using G.. (331)
Foreign voltage (10)
FiOS modem/router interfering with ne.. (7)
Browsers wont load websites (2)
Virus Doctor Popup? (1)
Dept. of HS: NSA 'Helped' Develop Vis.. (15)
Install XP pro and a Vista laptop ?? (9)
EVGA 9800 gtx help with finding a goo.. (8)
Modern Warfare For the PC (32)
Problem with speed step/turbo boost? (1)
Modern Warfare 2: Who Bought It? (61)
SIS 740 and Widescreen (8)
Baffling Problem with my CPU/MoBo's. .. (0)


All times are GMT -4. The time now is 11:23 PM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28