Pointing to a String with Pointers - C++ Data Type

C++ examples for Data Type:string

Description

Pointing to a String with Pointers

Demo Code

#include <iostream> 
#include <string> 
using namespace std; 

int main() //from   www .  j av a 2 s .  c om
{ 
  string s; 
  string *ptrToString; 
  
  s = "from  book2s.com"; 
  
  
  ptrToString = &s; 
  
  cout << *ptrToString << endl; 
  return 0; 
}

Result


Related Tutorials