A<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B_Tutorial%2FFile_Stream%2Fistrstream</id>
		<title>C++ Tutorial/File Stream/istrstream - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B_Tutorial%2FFile_Stream%2Fistrstream"/>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C%2B%2B_Tutorial/File_Stream/istrstream&amp;action=history"/>
		<updated>2026-04-17T19:44:34Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.cppe.ru/index.php?title=C%2B%2B_Tutorial/File_Stream/istrstream&amp;diff=2952&amp;oldid=prev</id>
		<title> в 14:21, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C%2B%2B_Tutorial/File_Stream/istrstream&amp;diff=2952&amp;oldid=prev"/>
				<updated>2010-05-25T14:21:17Z</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://www.cppe.ru/index.php?title=C%2B%2B_Tutorial/File_Stream/istrstream&amp;diff=2953&amp;oldid=prev</id>
		<title>Admin: 1 версия:&amp;#32;Импорт контента...</title>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C%2B%2B_Tutorial/File_Stream/istrstream&amp;diff=2953&amp;oldid=prev"/>
				<updated>2010-05-25T10:31:12Z</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;==Attempt to read from empty stream==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;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;
#include &amp;lt;sstream&amp;gt;&lt;br /&gt;
using std::istringstream;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   string input( &amp;quot;&amp;quot; );&lt;br /&gt;
   istringstream inputString( input );&lt;br /&gt;
   // attempt to read from empty stream&lt;br /&gt;
   long value;&lt;br /&gt;
   inputString &amp;gt;&amp;gt; value;&lt;br /&gt;
   if ( inputString.good() )&lt;br /&gt;
      cout &amp;lt;&amp;lt; &amp;quot;\n\nlong value is: &amp;quot; &amp;lt;&amp;lt; value &amp;lt;&amp;lt; endl;&lt;br /&gt;
   else&lt;br /&gt;
      cout &amp;lt;&amp;lt; &amp;quot;\n\ninputString is empty&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
   return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;inputString is empty&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Demonstrating input from an istringstream object==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;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;
#include &amp;lt;sstream&amp;gt;&lt;br /&gt;
using std::istringstream;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   string input( &amp;quot;Input test 123 4.7 A&amp;quot; );&lt;br /&gt;
   istringstream inputString( input );&lt;br /&gt;
   string string1;&lt;br /&gt;
   string string2;&lt;br /&gt;
   int integer;&lt;br /&gt;
   double double1;&lt;br /&gt;
   char character;&lt;br /&gt;
   inputString &amp;gt;&amp;gt; string1 &amp;gt;&amp;gt; string2 &amp;gt;&amp;gt; integer &amp;gt;&amp;gt; double1 &amp;gt;&amp;gt; character;&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;\nstring1: &amp;quot; &amp;lt;&amp;lt; string1&lt;br /&gt;
      &amp;lt;&amp;lt; &amp;quot;\nstring2: &amp;quot; &amp;lt;&amp;lt; string2 &amp;lt;&amp;lt; &amp;quot;\n   int: &amp;quot; &amp;lt;&amp;lt; integer&lt;br /&gt;
      &amp;lt;&amp;lt; &amp;quot;\ndouble: &amp;quot; &amp;lt;&amp;lt; double1 &amp;lt;&amp;lt; &amp;quot;\n  char: &amp;quot; &amp;lt;&amp;lt; character;&lt;br /&gt;
   return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;string1: Input&lt;br /&gt;
string2: test&lt;br /&gt;
   int: 123&lt;br /&gt;
double: 4.7&lt;br /&gt;
  char: A&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==How to read the contents of any array that contains text==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;strstream&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  char s[] = &amp;quot;1.3 this is a test &amp;lt;&amp;lt;&amp;gt;&amp;gt;&amp;lt;&amp;lt;?!\n&amp;quot;;&lt;br /&gt;
  istrstream ins(s);&lt;br /&gt;
  char ch;&lt;br /&gt;
  ins.unsetf(ios::skipws); // don&amp;quot;t skip spaces&lt;br /&gt;
  while (ins) { // false when end of array is reached&lt;br /&gt;
    ins &amp;gt;&amp;gt; ch;&lt;br /&gt;
    cout &amp;lt;&amp;lt; ch;&lt;br /&gt;
  }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;1.3 this is a test &amp;lt;&amp;lt;&amp;gt;&amp;gt;&amp;lt;&amp;lt;?!&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Read and display binary data==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;strstream&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  char *p = &amp;quot;this is a test\1\2\3\4\5\6\7&amp;quot;;&lt;br /&gt;
  istrstream ins(p);&lt;br /&gt;
  char ch;&lt;br /&gt;
  &lt;br /&gt;
  while (!ins.eof()) {&lt;br /&gt;
    ins.get(ch);&lt;br /&gt;
    cout &amp;lt;&amp;lt; hex &amp;lt;&amp;lt; (int) ch &amp;lt;&amp;lt; &amp;quot; &amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;74 68 69 73 20 69 73 20 61 20 74 65 73 74 1 2 3 4 5 6 7 7 &amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use istrstream to read int, float and char==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;strstream&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  char s[] = &amp;quot;10 Hello 0x75 42.73 OK&amp;quot;;&lt;br /&gt;
  istrstream ins(s);&lt;br /&gt;
  int i;&lt;br /&gt;
  char str[80];&lt;br /&gt;
  float f;&lt;br /&gt;
  // reading: 10 Hello&lt;br /&gt;
  ins &amp;gt;&amp;gt; i;&lt;br /&gt;
  ins &amp;gt;&amp;gt; str;&lt;br /&gt;
  cout &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &amp;quot; &amp;quot; &amp;lt;&amp;lt; str &amp;lt;&amp;lt; endl;&lt;br /&gt;
  // reading 0x75 42.73 OK&lt;br /&gt;
  ins &amp;gt;&amp;gt; hex &amp;gt;&amp;gt; i;&lt;br /&gt;
  ins &amp;gt;&amp;gt; f;&lt;br /&gt;
  ins &amp;gt;&amp;gt; str;&lt;br /&gt;
  cout &amp;lt;&amp;lt; hex &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &amp;quot; &amp;quot; &amp;lt;&amp;lt; f &amp;lt;&amp;lt; &amp;quot; &amp;quot; &amp;lt;&amp;lt; str;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;10 Hello&lt;br /&gt;
75 42.73 OK&amp;quot;&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>