C++ examples for Function:Function Parameter
Pass a pointer into a function to modify the variable outside functions
#include <iostream> using namespace std; void f(int* p) { cout << "p = " << p << endl; cout << "*p = " << *p << endl; *p = 5;//from ww w . ja v a2s .com cout << "p = " << p << endl; } int main() { int x = 47; cout << "x = " << x << endl; cout << "&x = " << &x << endl; f(&x); cout << "x = " << x << endl; }