Passing Arguments by Value : string data « String « C++






Passing Arguments by Value

Passing Arguments by Value
   
#include <iostream>
#include <string>
using namespace std;
void printMessage(string);  

int main ()
{
   string str;
   cout << "Enter a string: ";
   cin >> str;
   printMessage(str); 
   return 0;
}
void printMessage (string s)
{
   cout << "You inputted " << s;
}
  
    
    
  








Related examples in the same category

1.Use char pointer to point to the char array returned from string.data()