<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Komplettes File in std::string speichern]]></title><description><![CDATA[<p>Huhu</p>
<p>würde gerne wissen wie sowas geht.<br />
Hab ein Beispiel im Internet gefunden:</p>
<pre><code class="language-cpp">Andere Methode: Datei in einem Rutsch einlesen und ausgeben

#include &lt;iostream&gt; // wegen cout cin
#include &lt;fstream&gt; // wegen Dateistreamobjekt
#include &lt;string&gt; // wegen Datentyp string
#include &lt;iterator&gt; 
using namespace std;

int main(int argc, char *argv)
{
            string fileName = &quot;c:\\test.txt&quot;;
            ifstream inFile(fileName.c_str()); 
            string fileData((istreambuf_iterator &lt; char&gt; (inFile)), istreambuf_iterator &lt; char&gt; ());
            cout &lt;&lt; fileData;
            cin.get();
            return 0;
}
</code></pre>
<p>Jedoch erkennt er &gt;&gt; istreambuf_iterator&lt;char&gt; &lt;&lt; nicht</p>
<p>Ich versuche nämlich ein ganzes File in einen std::string abzuspeichern.<br />
Gibt es eine andere Lösung?</p>
<p>Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/251748/komplettes-file-in-std-string-speichern</link><generator>RSS for Node</generator><lastBuildDate>Tue, 15 Sep 2026 07:43:25 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/251748.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 09 Oct 2009 17:39:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Komplettes File in std::string speichern on Fri, 09 Oct 2009 17:39:14 GMT]]></title><description><![CDATA[<p>Huhu</p>
<p>würde gerne wissen wie sowas geht.<br />
Hab ein Beispiel im Internet gefunden:</p>
<pre><code class="language-cpp">Andere Methode: Datei in einem Rutsch einlesen und ausgeben

#include &lt;iostream&gt; // wegen cout cin
#include &lt;fstream&gt; // wegen Dateistreamobjekt
#include &lt;string&gt; // wegen Datentyp string
#include &lt;iterator&gt; 
using namespace std;

int main(int argc, char *argv)
{
            string fileName = &quot;c:\\test.txt&quot;;
            ifstream inFile(fileName.c_str()); 
            string fileData((istreambuf_iterator &lt; char&gt; (inFile)), istreambuf_iterator &lt; char&gt; ());
            cout &lt;&lt; fileData;
            cin.get();
            return 0;
}
</code></pre>
<p>Jedoch erkennt er &gt;&gt; istreambuf_iterator&lt;char&gt; &lt;&lt; nicht</p>
<p>Ich versuche nämlich ein ganzes File in einen std::string abzuspeichern.<br />
Gibt es eine andere Lösung?</p>
<p>Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1790291</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1790291</guid><dc:creator><![CDATA[StringTanga]]></dc:creator><pubDate>Fri, 09 Oct 2009 17:39:14 GMT</pubDate></item><item><title><![CDATA[Reply to Komplettes File in std::string speichern on Fri, 09 Oct 2009 18:06:22 GMT]]></title><description><![CDATA[<p>Geschafft...Stringstream sei dank</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1790307</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1790307</guid><dc:creator><![CDATA[StringTanga]]></dc:creator><pubDate>Fri, 09 Oct 2009 18:06:22 GMT</pubDate></item><item><title><![CDATA[Reply to Komplettes File in std::string speichern on Fri, 09 Oct 2009 18:11:35 GMT]]></title><description><![CDATA[<p>gib mal bitte die konkrete fehlermeldung</p>
<p>der msvc9.0 schluckt das ganze:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt; // wegen cout cin 
#include &lt;fstream&gt; // wegen Dateistreamobjekt 
#include &lt;string&gt; // wegen Datentyp string 
#include &lt;iterator&gt; 
using namespace std; 

int main()
{ 
  string fileName = &quot;c:\\test.txt&quot;; 
  ifstream inFile(fileName.c_str()); 
  string fileData((istreambuf_iterator &lt; char&gt; (inFile)), istreambuf_iterator &lt; char&gt; ()); 
  cout &lt;&lt; fileData; 
  cin.get(); 
}
</code></pre>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1790312</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1790312</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Fri, 09 Oct 2009 18:11:35 GMT</pubDate></item><item><title><![CDATA[Reply to Komplettes File in std::string speichern on Fri, 09 Oct 2009 20:51:24 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">string str;
ifstream in( &quot;file.txt&quot; );
ostringstream oss;

	oss &lt;&lt; in.rdbuf();
	str = oss.str();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1790389</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1790389</guid><dc:creator><![CDATA[EOP]]></dc:creator><pubDate>Fri, 09 Oct 2009 20:51:24 GMT</pubDate></item><item><title><![CDATA[Reply to Komplettes File in std::string speichern on Sat, 10 Oct 2009 13:57:57 GMT]]></title><description><![CDATA[<p>na klasse...</p>
<p>dann nimm doch:<br />
<code>string fileData((istream_iterator&lt;char&gt;(inFile)), istream_iterator&lt;char&gt;());</code></p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1790582</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1790582</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sat, 10 Oct 2009 13:57:57 GMT</pubDate></item></channel></rss>