Convert string to C-Style string : string char array « String « C++






Convert string to C-Style string

 
 

#include <iostream>
using std::cout;
using std::endl;

#include <string>
using std::string;

int main()
{
   string string1( "STRINGS" );

   cout << "string string1 is " << string1
      << "\nstring1 converted to a C-Style string is "
      << string1.c_str() << "\n";


   return 0;
}

/* 
string string1 is STRINGS
string1 converted to a C-Style string is STRINGS

 */        
  








Related examples in the same category