<?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[Fehlerabfrage bei ifstream]]></title><description><![CDATA[<p>Hallo,<br />
habe folgenden code:</p>
<pre><code class="language-cpp">ifstream _in(str_IniPath.c_str());
	int bracketpos;

	while(getline(_in,line))
        {.....
        }
</code></pre>
<p>Wie kann ich nun abfragen, ob _in nun tatsächlich str_IniPath oeffnen konnte?<br />
(vgl. fopen(....))<br />
danke<br />
t. o.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/246452/fehlerabfrage-bei-ifstream</link><generator>RSS for Node</generator><lastBuildDate>Fri, 18 Sep 2026 00:21:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/246452.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 28 Jul 2009 14:21:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fehlerabfrage bei ifstream on Tue, 28 Jul 2009 14:21:39 GMT]]></title><description><![CDATA[<p>Hallo,<br />
habe folgenden code:</p>
<pre><code class="language-cpp">ifstream _in(str_IniPath.c_str());
	int bracketpos;

	while(getline(_in,line))
        {.....
        }
</code></pre>
<p>Wie kann ich nun abfragen, ob _in nun tatsächlich str_IniPath oeffnen konnte?<br />
(vgl. fopen(....))<br />
danke<br />
t. o.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1750953</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1750953</guid><dc:creator><![CDATA[Theresa O.]]></dc:creator><pubDate>Tue, 28 Jul 2009 14:21:39 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlerabfrage bei ifstream on Tue, 28 Jul 2009 14:43:41 GMT]]></title><description><![CDATA[<p>Vielleicht mit is_open()?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1750969</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1750969</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Tue, 28 Jul 2009 14:43:41 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlerabfrage bei ifstream on Tue, 28 Jul 2009 23:27:21 GMT]]></title><description><![CDATA[<p>Theresa O. schrieb:</p>
<blockquote>
<p>Hallo,<br />
habe folgenden code:</p>
<pre><code class="language-cpp">ifstream _in(str_IniPath.c_str());
	int bracketpos;

	while(getline(_in,line))
        {.....
        }
</code></pre>
<p>Wie kann ich nun abfragen, ob _in nun tatsächlich str_IniPath oeffnen konnte?<br />
(vgl. fopen(....))<br />
danke<br />
t. o.</p>
</blockquote>
<pre><code class="language-cpp">ifstream _in(str_IniPath.c_str());
   if(!_in) {
      std::cerr &lt;&lt; &quot;Cant open &quot; &lt;&lt; str_IniPath &lt;&lt; std::endl;
      return;
   }
   int bracketpos;

   while(getline(_in, line)) {

      // ...

   }
   if(!_in.eof())
      std::cerr &lt;&lt; &quot;Error reading from &quot; &lt;&lt; str_IniPath &lt;&lt; std::endl;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1751264</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1751264</guid><dc:creator><![CDATA[DStefan]]></dc:creator><pubDate>Tue, 28 Jul 2009 23:27:21 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlerabfrage bei ifstream on Wed, 29 Jul 2009 07:30:27 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">std::ifstream reader;
reader.exceptions ( std::ifstream::eofbit | std::ifstream::failbit | std::ifstream::badbit );
try
{
    reader.open(&quot;some.file&quot;);
    while(std::getline(reader, line)
    {
        //...
    }
}
catch(std::exception &amp; e)
{
    std::cerr &lt;&lt; e.what() &lt;&lt; '\n';
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1751323</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1751323</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Wed, 29 Jul 2009 07:30:27 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlerabfrage bei ifstream on Thu, 30 Jul 2009 08:02:02 GMT]]></title><description><![CDATA[<p>Danke für die Hilfe.<br />
Aber wo kann ich mir ifstream genauer ansehen?<br />
Stichwort: std::ifstream::eofbit | std::ifstream::failbit | std::ifstream::badbit<br />
Grüsse<br />
T.O.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1752074</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1752074</guid><dc:creator><![CDATA[Theresa O.]]></dc:creator><pubDate>Thu, 30 Jul 2009 08:02:02 GMT</pubDate></item></channel></rss>