- Code: Select all
#include "stdafx.h"
#include <iostream>
using namespace std;
void divide2(int * ptr);
int main()
{
int x = 10;
int y = 20;
int * pointer = &x;
cout << "x = " << x << " and it's address is " << pointer << endl;
divide2(pointer);
divide2( & y );
cout << "x is now = " << x << " and y is now " << y << endl;
system("pause");
}
void divide2(int * ptr)
{
(*ptr) = (*ptr)/2;
}
Basically this was a practice for transferring varibles in between functions as well as pointers, what it does is divide by 2. :O
