home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C Programming Starter Kit 2.0
/
SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso
/
tybc4
/
ptr1.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-27
|
525b
|
24 lines
/*
C++ program that demonstrates pointers to existing variables
*/
#include <iostream.h>
main()
{
int x = 10;
int* px = &x;
// display x using x and rx
cout << "x contains " << x << "\n";
cout << "x contains (using the pointer px) "
<< *px << "\n";
// alter x and display its value using *px
x *= 2;
cout << "x contains (using the pointer px) "
<< *px << "\n";
// alter *px and display value using x
*px *= 2;
cout << "x contains " << x << "\n";
return 0;
}