C++ Function Parameter passing by address to change a variable in the called function

Introduction

and to keep those changes in effect in the caller function

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



PreviousNext

Related