<?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[ifstream]]></title><description><![CDATA[<p>Hallo,<br />
Ich möchte Werte aus mehreren Files ausgeben. Dazu habe ich einen ifstream definiert, den ich für zwei Files benutzen möchte. Beim ersten funktionert es wunderbar, beim zweiten File geht es jedoch nicht mehr. Ist es überhaupt möglich den selben Stream für mehrere Files zu verwenden?</p>
<pre><code>ifstream file;
char temp[255];
file.open(&quot;text1.txt&quot;,ios::in);
while(!file.eof())
{
   file &gt;&gt; temp;
   cout &lt;&lt; temp&lt;&lt;endl;
}
file.close();
file.open(&quot;text2.txt&quot;,ios::in);
while(!file.eof())
{
   file &gt;&gt; temp;
   cout &lt;&lt; temp&lt;&lt;endl;
}
file.close();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/99738/ifstream</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Jul 2026 22:42:39 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/99738.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 31 Jan 2005 12:57:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ifstream on Mon, 31 Jan 2005 12:57:52 GMT]]></title><description><![CDATA[<p>Hallo,<br />
Ich möchte Werte aus mehreren Files ausgeben. Dazu habe ich einen ifstream definiert, den ich für zwei Files benutzen möchte. Beim ersten funktionert es wunderbar, beim zweiten File geht es jedoch nicht mehr. Ist es überhaupt möglich den selben Stream für mehrere Files zu verwenden?</p>
<pre><code>ifstream file;
char temp[255];
file.open(&quot;text1.txt&quot;,ios::in);
while(!file.eof())
{
   file &gt;&gt; temp;
   cout &lt;&lt; temp&lt;&lt;endl;
}
file.close();
file.open(&quot;text2.txt&quot;,ios::in);
while(!file.eof())
{
   file &gt;&gt; temp;
   cout &lt;&lt; temp&lt;&lt;endl;
}
file.close();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/711132</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/711132</guid><dc:creator><![CDATA[wedmer]]></dc:creator><pubDate>Mon, 31 Jan 2005 12:57:52 GMT</pubDate></item><item><title><![CDATA[Reply to ifstream on Mon, 31 Jan 2005 13:19:33 GMT]]></title><description><![CDATA[<p>Was genau funktioniert denn nicht? Hast du schon mal mit dem Debugger geprüft ob er überhaupt in die Schleife geht? Bzw. was genau schief läuft?</p>
<p>-junix</p>
]]></description><link>https://www.c-plusplus.net/forum/post/711153</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/711153</guid><dc:creator><![CDATA[junix]]></dc:creator><pubDate>Mon, 31 Jan 2005 13:19:33 GMT</pubDate></item><item><title><![CDATA[Reply to ifstream on Mon, 31 Jan 2005 13:29:34 GMT]]></title><description><![CDATA[<p>Ja er geht in die Schleife und gibt mir die letzte Zeile vom File text1.txt aus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/711167</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/711167</guid><dc:creator><![CDATA[wedmer]]></dc:creator><pubDate>Mon, 31 Jan 2005 13:29:34 GMT</pubDate></item><item><title><![CDATA[Reply to ifstream on Mon, 31 Jan 2005 13:30:37 GMT]]></title><description><![CDATA[<p>ich glaub junix meinte die 2te</p>
]]></description><link>https://www.c-plusplus.net/forum/post/711170</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/711170</guid><dc:creator><![CDATA[Beliah]]></dc:creator><pubDate>Mon, 31 Jan 2005 13:30:37 GMT</pubDate></item><item><title><![CDATA[Reply to ifstream on Mon, 31 Jan 2005 13:31:21 GMT]]></title><description><![CDATA[<p>Verfügt file2 überhaupt über Inhalt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/711174</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/711174</guid><dc:creator><![CDATA[junix]]></dc:creator><pubDate>Mon, 31 Jan 2005 13:31:21 GMT</pubDate></item><item><title><![CDATA[Reply to ifstream on Mon, 31 Jan 2005 13:38:53 GMT]]></title><description><![CDATA[<p>Ja text2.txt verfügt über einen Inhalt.</p>
<p>Den Inhalt des ersten Files wird korrekt ausgegeben.<br />
Vom zweiten leider gar nichts, bloss noch einmal die letzte Zeile vom File 1.<br />
Benutze ich auf File2 einen anderen Stream als auf file1 funktioniert es. Wieso kann ich nicht den selben Stream auf beide Files anwenden???</p>
]]></description><link>https://www.c-plusplus.net/forum/post/711185</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/711185</guid><dc:creator><![CDATA[wedmer]]></dc:creator><pubDate>Mon, 31 Jan 2005 13:38:53 GMT</pubDate></item><item><title><![CDATA[Reply to ifstream on Mon, 31 Jan 2005 13:51:48 GMT]]></title><description><![CDATA[<p>Weil der stream anscheinend eof nicht selbst zurücksetzt beim close.<br />
Wenn du aber eine möglichkeit findest wie du eof manuell 'clearen' kannst sollte es gehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/711200</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/711200</guid><dc:creator><![CDATA[Beliah]]></dc:creator><pubDate>Mon, 31 Jan 2005 13:51:48 GMT</pubDate></item><item><title><![CDATA[Reply to ifstream on Mon, 31 Jan 2005 14:32:34 GMT]]></title><description><![CDATA[<p>Hat jemand ne ahnung, wie ich den manuell clearen kann?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/711254</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/711254</guid><dc:creator><![CDATA[wedmer]]></dc:creator><pubDate>Mon, 31 Jan 2005 14:32:34 GMT</pubDate></item><item><title><![CDATA[Reply to ifstream on Mon, 31 Jan 2005 14:39:40 GMT]]></title><description><![CDATA[<p>...</p>
<p>file.clear();</p>
]]></description><link>https://www.c-plusplus.net/forum/post/711263</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/711263</guid><dc:creator><![CDATA[Beliah]]></dc:creator><pubDate>Mon, 31 Jan 2005 14:39:40 GMT</pubDate></item><item><title><![CDATA[Reply to ifstream on Mon, 31 Jan 2005 14:51:02 GMT]]></title><description><![CDATA[<p>Funktioniert danke schön.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/711279</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/711279</guid><dc:creator><![CDATA[wedmer]]></dc:creator><pubDate>Mon, 31 Jan 2005 14:51:02 GMT</pubDate></item></channel></rss>