Unlike passing by value, passing by address gives you the ability to change a variable in the called function and to keep those changes in effect in the caller function. - C++ Function

C++ examples for Function:Function Parameter

Description

Unlike passing by value, passing by address gives you the ability to change a variable in the called function and to keep those changes in effect in the caller function.

Demo Code

#include <iostream>
using namespace std;
#include <string.h>
int change_it(char c[4]);   
int main()/*from  w  w  w.  j  a va  2 s .co  m*/
{
   char name[4]="ABC";
   change_it(name);     
   cout << name << "\n";
   return 0;
}
int change_it(char c[4])    
{
   cout << c << "\n";   
   strcpy(c, "USA");    
   return 0;
}

Result


Related Tutorials