Monday, April 18, 2011

C/C++ pointer exercise: Pointer Dereferencing

#include <iostream>

int main(int argc, char *argv[])
{
int var1 = 5;
int *pointer = &var1;
int var2 = *pointer;

std::cout << "var1 = " << var1 << "\n";
std::cout << "pointer = " << pointer << "\n";
std::cout << "*pointer = " << *pointer << "\n";
std::cout << "var2 = " << var2 << "\n";

std::cout << "\n";
}


c pointer exercise: Pointer Dereferencing