<?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[Anzahl Zeilen einer Datei]]></title><description><![CDATA[<p>Hallo! Ich versuche die Anzahl der Zeilen einer Datei zuermitteln:</p>
<pre><code class="language-cpp">f = fopen(&quot;entries.txt&quot;,&quot;r&quot;);

	int countMe = 0;
	char* e;
while (fgets(e,255,f) != NULL) {
		countMe++;
}
</code></pre>
<p>Scheitert leider beim letzen Zugriff von fgets auf die &quot;letzte&quot; nicht vorhandene Zeile.<br />
Was nun? Gibts vielleicht ne Funktion dazu, die ich niocht kenne?</p>
<p>Gruß Jörg</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/161196/anzahl-zeilen-einer-datei</link><generator>RSS for Node</generator><lastBuildDate>Fri, 11 Sep 2026 18:09:29 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/161196.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 04 Oct 2006 11:29:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Anzahl Zeilen einer Datei on Wed, 04 Oct 2006 11:29:31 GMT]]></title><description><![CDATA[<p>Hallo! Ich versuche die Anzahl der Zeilen einer Datei zuermitteln:</p>
<pre><code class="language-cpp">f = fopen(&quot;entries.txt&quot;,&quot;r&quot;);

	int countMe = 0;
	char* e;
while (fgets(e,255,f) != NULL) {
		countMe++;
}
</code></pre>
<p>Scheitert leider beim letzen Zugriff von fgets auf die &quot;letzte&quot; nicht vorhandene Zeile.<br />
Was nun? Gibts vielleicht ne Funktion dazu, die ich niocht kenne?</p>
<p>Gruß Jörg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149159</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149159</guid><dc:creator><![CDATA[joergh]]></dc:creator><pubDate>Wed, 04 Oct 2006 11:29:31 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl Zeilen einer Datei on Wed, 04 Oct 2006 11:31:02 GMT]]></title><description><![CDATA[<p>versuch's mal mit feof(), um das Dateiende abzufangen.</p>
<p>(btw solltest du e auch auf irgendwas zeigen lassen, was groß genug für 255 Zeichen ist)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149161</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149161</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 04 Oct 2006 11:31:02 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl Zeilen einer Datei on Wed, 04 Oct 2006 11:50:15 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">f = fopen(&quot;entries.txt&quot;,&quot;r&quot;);

	int countMe = 0;
	char* e;
	while(!feof(f)) {
		fgets(e,255,f);
		countMe++;
	}
</code></pre>
<p>Stürzt auch ab...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149179</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149179</guid><dc:creator><![CDATA[joergh]]></dc:creator><pubDate>Wed, 04 Oct 2006 11:50:15 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl Zeilen einer Datei on Wed, 04 Oct 2006 11:58:00 GMT]]></title><description><![CDATA[<p>joergh schrieb:</p>
<blockquote>
<pre><code class="language-cpp">f = fopen(&quot;entries.txt&quot;,&quot;r&quot;);

	int countMe = 0;
	char* e;
	while(!feof(f)) {
		fgets(e,255,f);
		countMe++;
	}
</code></pre>
<p>Stürzt auch ab...</p>
</blockquote>
<p>joah, weil e immer noch keinen gültigen Speicher hat.<br />
Mach mal:</p>
<pre><code class="language-cpp">char *e = static_cast&lt;char*&gt;( calloc(256, sizeof(*e)) );
//dein Code
free(e);
</code></pre>
<p>MfG</p>
<p>GPC</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149188</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149188</guid><dc:creator><![CDATA[GPC]]></dc:creator><pubDate>Wed, 04 Oct 2006 11:58:00 GMT</pubDate></item></channel></rss>