A<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B%2FString%2Fstring</id>
		<title>C++/String/string - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B%2FString%2Fstring"/>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B/String/string&amp;action=history"/>
		<updated>2026-04-10T06:28:26Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B/String/string&amp;diff=1416&amp;oldid=prev</id>
		<title> в 14:21, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B/String/string&amp;diff=1416&amp;oldid=prev"/>
				<updated>2010-05-25T14:21:06Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 14:21, 25 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B/String/string&amp;diff=1417&amp;oldid=prev</id>
		<title>Admin: 1 версия:&amp;#32;Импорт контента...</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B/String/string&amp;diff=1417&amp;oldid=prev"/>
				<updated>2010-05-25T10:25:48Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия: Импорт контента...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==A short string demonstration.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;  &lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
   &lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  string str1(&amp;quot;A&amp;quot;);&lt;br /&gt;
  string str2(&amp;quot;B&amp;quot;);&lt;br /&gt;
  string str3(&amp;quot;O&amp;quot;);&lt;br /&gt;
  string str4;&lt;br /&gt;
   &lt;br /&gt;
  str4 = str1;&lt;br /&gt;
  cout &amp;lt;&amp;lt; str1 &amp;lt;&amp;lt; &amp;quot;\n&amp;quot; &amp;lt;&amp;lt; str3 &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
   &lt;br /&gt;
  str4 = str1 + str2;&lt;br /&gt;
  cout &amp;lt;&amp;lt; str4 &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
   &lt;br /&gt;
  str4 = str1 + &amp;quot; to &amp;quot; + str3;&lt;br /&gt;
  cout &amp;lt;&amp;lt; str4 &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
   &lt;br /&gt;
  if(str3 &amp;gt; str1) &lt;br /&gt;
     cout &amp;lt;&amp;lt; &amp;quot;str3 &amp;gt; str1\n&amp;quot;;&lt;br /&gt;
  if(str3 == str1+str2)&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;str3 == str1+str2\n&amp;quot;;&lt;br /&gt;
   &lt;br /&gt;
  str1 = &amp;quot;This is a null-terminated string.\n&amp;quot;;&lt;br /&gt;
  cout &amp;lt;&amp;lt; str1;&lt;br /&gt;
   &lt;br /&gt;
  string str5(str1);&lt;br /&gt;
  cout &amp;lt;&amp;lt; str5;&lt;br /&gt;
   &lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Enter a string: &amp;quot;;&lt;br /&gt;
  cin &amp;gt;&amp;gt; str5;&lt;br /&gt;
  cout &amp;lt;&amp;lt; str5;&lt;br /&gt;
   &lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Changing Case in Strings==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;  &lt;br /&gt;
#include &amp;lt;algorithm&amp;gt;&lt;br /&gt;
#include &amp;lt;cctype&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
inline&lt;br /&gt;
char my_tolower( char c )&lt;br /&gt;
{  return&lt;br /&gt;
   static_cast&amp;lt;char&amp;gt;( tolower( static_cast&amp;lt;unsigned char&amp;gt;( c ) ) );&lt;br /&gt;
}&lt;br /&gt;
inline&lt;br /&gt;
char my_toupper( char c )&lt;br /&gt;
{  return&lt;br /&gt;
   static_cast&amp;lt;char&amp;gt;( toupper( static_cast&amp;lt;unsigned char&amp;gt;( c ) ) );&lt;br /&gt;
}&lt;br /&gt;
int main( )&lt;br /&gt;
{&lt;br /&gt;
   string book( &amp;quot;The C++ Programming Language, 3rd Edition&amp;quot; );&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;String:&amp;quot; &amp;lt;&amp;lt; book &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl;&lt;br /&gt;
   transform( book.begin(), book.end(), book.begin(), my_toupper );&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Big letters:&amp;quot; &amp;lt;&amp;lt; book &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl;&lt;br /&gt;
   transform( book.begin(), book.end(), book.begin(), my_tolower );&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Small letters:&amp;quot; &amp;lt;&amp;lt; book;&lt;br /&gt;
}&lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Char Escapes==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;  &lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    string y1( &amp;quot;a\x62&amp;quot; );&lt;br /&gt;
    cout &amp;lt;&amp;lt; y1 &amp;lt;&amp;lt; endl;   // y1 is string &amp;quot;ab&amp;quot;.&lt;br /&gt;
                                                      &lt;br /&gt;
    string y6( &amp;quot;a\xef&amp;quot; );&lt;br /&gt;
    cout &amp;lt;&amp;lt; y6 &amp;lt;&amp;lt; endl;                               &lt;br /&gt;
                                                      &lt;br /&gt;
    string w1( &amp;quot;a\142&amp;quot; );&lt;br /&gt;
    cout &amp;lt;&amp;lt; w1 &amp;lt;&amp;lt; endl;                               &lt;br /&gt;
                                                      &lt;br /&gt;
    string w2( &amp;quot;a\142c&amp;quot; );&lt;br /&gt;
    cout &amp;lt;&amp;lt; w2 &amp;lt;&amp;lt; endl;                               &lt;br /&gt;
                                                      &lt;br /&gt;
    string w3( &amp;quot;a\142142&amp;quot; );&lt;br /&gt;
    cout &amp;lt;&amp;lt; w3 &amp;lt;&amp;lt; endl;                               &lt;br /&gt;
                                                      &lt;br /&gt;
    string w4( &amp;quot;a\79&amp;quot; );&lt;br /&gt;
    cout &amp;lt;&amp;lt; w4 &amp;lt;&amp;lt; endl;                               &lt;br /&gt;
                                                      &lt;br /&gt;
    string w5( &amp;quot;\x00007p\x0007q\x0007r\x007s\x07t\x7u&amp;quot; );&lt;br /&gt;
    &lt;br /&gt;
    cout &amp;lt;&amp;lt; w5 &amp;lt;&amp;lt; endl; &lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==copy constructor==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;  &lt;br /&gt;
 &lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
using std::cout;&lt;br /&gt;
using std::endl;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
using std::string;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   string s1( &amp;quot;AA1234567890asdfasdf&amp;quot; );&lt;br /&gt;
   string s2( &amp;quot; AAB&amp;quot; );&lt;br /&gt;
   string s3;&lt;br /&gt;
   // test copy constructor&lt;br /&gt;
   string *s4Ptr = new string( s1 );  &lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;\n*s4Ptr = &amp;quot; &amp;lt;&amp;lt; *s4Ptr &amp;lt;&amp;lt; &amp;quot;\n\n&amp;quot;;&lt;br /&gt;
   return 0;&lt;br /&gt;
}&lt;br /&gt;
 /* &lt;br /&gt;
*s4Ptr = AA1234567890asdfasdf&lt;br /&gt;
&lt;br /&gt;
 */       &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Define a string variable, assign a value and display it==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;  &lt;br /&gt;
 &lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
using namespace std ;&lt;br /&gt;
using std::cout;       &lt;br /&gt;
using std::cin;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  string s = &amp;quot;www.java2s.com \n&amp;quot;;&lt;br /&gt;
  cout &amp;lt;&amp;lt;s; &lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
/* &lt;br /&gt;
www.java2s.com&lt;br /&gt;
 */&lt;br /&gt;
        &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Extracting Words in Strings Delimited by Whitespace==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;  &lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;iterator&amp;gt;&lt;br /&gt;
#include &amp;lt;sstream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt; &lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
int main( )&lt;br /&gt;
{&lt;br /&gt;
   string text( &amp;quot;this is a test&amp;quot; ); &lt;br /&gt;
   istringstream stream( text ); &lt;br /&gt;
   // make a vector with each word of the text&lt;br /&gt;
   vector&amp;lt; string &amp;gt; words( (istream_iterator&amp;lt;string&amp;gt;( stream )),istream_iterator&amp;lt;string&amp;gt;() ); &lt;br /&gt;
   cout &amp;lt;&amp;lt; words.size() &amp;lt;&amp;lt; &amp;quot; : &amp;quot; &amp;lt;&amp;lt; text;&lt;br /&gt;
}&lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Loop through the string array==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;  &lt;br /&gt;
 &lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;list&amp;gt;&lt;br /&gt;
#include &amp;lt;algorithm&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main( ) {&lt;br /&gt;
   string arrStr[5] = {&amp;quot;A&amp;quot;, &amp;quot;B&amp;quot;, &amp;quot;C&amp;quot;, &amp;quot;D&amp;quot;, &amp;quot;E&amp;quot;};&lt;br /&gt;
   for (string* p = &amp;amp;arrStr[0]; p != &amp;amp;arrStr[5]; ++p) {&lt;br /&gt;
      cout &amp;lt;&amp;lt; *p &amp;lt;&amp;lt; endl;&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
/* &lt;br /&gt;
A&lt;br /&gt;
B&lt;br /&gt;
C&lt;br /&gt;
D&lt;br /&gt;
E&lt;br /&gt;
 */        &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==string basics==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;  &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  string str1(&amp;quot;Alpha&amp;quot;);&lt;br /&gt;
  string str2(&amp;quot;Beta&amp;quot;);&lt;br /&gt;
  string str3(&amp;quot;Omega&amp;quot;);&lt;br /&gt;
  string str4;&lt;br /&gt;
  // assign a string&lt;br /&gt;
  str4 = str1; &lt;br /&gt;
  cout &amp;lt;&amp;lt; str1 &amp;lt;&amp;lt; &amp;quot;\n&amp;quot; &amp;lt;&amp;lt; str3 &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
  // concatenate two strings&lt;br /&gt;
  str4 = str1 + str2; &lt;br /&gt;
  cout &amp;lt;&amp;lt; str4 &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
  // concatenate a string with a C-string&lt;br /&gt;
  str4 = str1 + &amp;quot; to &amp;quot; + str3;&lt;br /&gt;
  cout &amp;lt;&amp;lt; str4 &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
  // compare strings&lt;br /&gt;
  if(str3 &amp;gt; str1) cout &amp;lt;&amp;lt; &amp;quot;str3 &amp;gt; str1\n&amp;quot;;&lt;br /&gt;
  if(str3 == str1+str2)&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;str3 == str1+str2\n&amp;quot;;&lt;br /&gt;
  /* A string object can also be &lt;br /&gt;
     assigned a normal string. */&lt;br /&gt;
  str1 = &amp;quot;This is a null-terminated string.\n&amp;quot;;&lt;br /&gt;
  cout &amp;lt;&amp;lt; str1;&lt;br /&gt;
  // create a string object using another string object&lt;br /&gt;
  string str5(str1);&lt;br /&gt;
  cout &amp;lt;&amp;lt; str5;&lt;br /&gt;
  // input a string&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Enter a string: &amp;quot;;&lt;br /&gt;
  cin &amp;gt;&amp;gt; str5;&lt;br /&gt;
  cout &amp;lt;&amp;lt; str5;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
/* &lt;br /&gt;
Alpha&lt;br /&gt;
Omega&lt;br /&gt;
AlphaBeta&lt;br /&gt;
Alpha to Omega&lt;br /&gt;
str3 &amp;gt; str1&lt;br /&gt;
This is a null-terminated string.&lt;br /&gt;
This is a null-terminated string.&lt;br /&gt;
Enter a string: a string&lt;br /&gt;
a&lt;br /&gt;
 */        &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>