<?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[Alles was nach while Schleife kommt nicht beachtet...]]></title><description><![CDATA[<p>Hi,<br />
ich habe ein Problem, bei dem ich auf keinen grünen Zweig komme. Alles, was nach der while Schleife im folgenden Quellcode kommt, wird nicht beachtet und einfach nicht ausgeführt,</p>
<pre><code class="language-cpp">void* red_function(void *data) {
	///Variables declaration
	fstream f;
	string in;
	ifstream input;

	///Open readable stream
	input.open(&quot;cpp.ppm&quot;);
	///Initialize the variables
	int farbe = 0;
	int zahl = 0;
	int i = 0;
	///Read the first line
	getline(input, in);
	///Run through the file
	cout &lt;&lt; &quot;Hallo&quot; &lt;&lt; endl;
	while(!input.eof()) {
		///If an unusable string was found
		if(((signed int)in.find(&quot;#&quot;, 0) != -1) || ((signed int)in.find( &quot;P3&quot;, 0 ) != -1)) {
			///Get the next line
			getline(input, in);
			///And continue with the next step in the while loop
			continue;
		}
		///If i is 0
		if(i == 0) {
			///Increase i
			i++;
			///and read the next line
			getline(input, in);
			continue;
			///if i is 1
		}else if(i == 1) {
			///increase i
			i++;
			///initialize a stringstream
			stringstream sstr(in);
			///and pipe it into an integer
			sstr &gt;&gt; zahl;
			///initialize the array for the red values
			red = new int[zahl+2];
			///put an ending condition to the end
			red[zahl+1] = -1;
			///get the next line
			getline(input, in);
			continue;
			///if i is 2
		} else if(i == 2) {
			///if farbe is 0, increase the value in the array for the red values
			///at the position of the fitting value
			if(farbe == 0) {
				stringstream sstr(in);
				sstr &gt;&gt; zahl;
				red[zahl] += 1;
				farbe++;
			}
			else if(farbe == 1){
				farbe++;
			}
			else if(farbe == 2) {
				cout &lt;&lt; farbe &lt;&lt; endl;
				farbe = 0;
			}
			getline(input, in);
			continue;
		}
	}
	///Close the input-stream
	input.close();
	///Pipe the values into the file
	f.open(&quot;red_histogram.dat&quot;, ios::out);
	for (int j = 0; red[j] != -1; j++) {
		cout &lt;&lt; j &lt;&lt; &quot; &quot; &lt;&lt; red[j] &lt;&lt; endl;
		f &lt;&lt; j &lt;&lt; &quot; &quot; &lt;&lt; red[j] &lt;&lt; endl;
	}
	f.close();
	return NULL;
}
</code></pre>
<p>Ich hoffe irgendwer sieht den Fehler.</p>
<p>Liebe Grüße</p>
<p>René</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/259476/alles-was-nach-while-schleife-kommt-nicht-beachtet</link><generator>RSS for Node</generator><lastBuildDate>Tue, 08 Sep 2026 20:34:19 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/259476.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 23 Jan 2010 16:33:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Alles was nach while Schleife kommt nicht beachtet... on Sat, 23 Jan 2010 16:33:12 GMT]]></title><description><![CDATA[<p>Hi,<br />
ich habe ein Problem, bei dem ich auf keinen grünen Zweig komme. Alles, was nach der while Schleife im folgenden Quellcode kommt, wird nicht beachtet und einfach nicht ausgeführt,</p>
<pre><code class="language-cpp">void* red_function(void *data) {
	///Variables declaration
	fstream f;
	string in;
	ifstream input;

	///Open readable stream
	input.open(&quot;cpp.ppm&quot;);
	///Initialize the variables
	int farbe = 0;
	int zahl = 0;
	int i = 0;
	///Read the first line
	getline(input, in);
	///Run through the file
	cout &lt;&lt; &quot;Hallo&quot; &lt;&lt; endl;
	while(!input.eof()) {
		///If an unusable string was found
		if(((signed int)in.find(&quot;#&quot;, 0) != -1) || ((signed int)in.find( &quot;P3&quot;, 0 ) != -1)) {
			///Get the next line
			getline(input, in);
			///And continue with the next step in the while loop
			continue;
		}
		///If i is 0
		if(i == 0) {
			///Increase i
			i++;
			///and read the next line
			getline(input, in);
			continue;
			///if i is 1
		}else if(i == 1) {
			///increase i
			i++;
			///initialize a stringstream
			stringstream sstr(in);
			///and pipe it into an integer
			sstr &gt;&gt; zahl;
			///initialize the array for the red values
			red = new int[zahl+2];
			///put an ending condition to the end
			red[zahl+1] = -1;
			///get the next line
			getline(input, in);
			continue;
			///if i is 2
		} else if(i == 2) {
			///if farbe is 0, increase the value in the array for the red values
			///at the position of the fitting value
			if(farbe == 0) {
				stringstream sstr(in);
				sstr &gt;&gt; zahl;
				red[zahl] += 1;
				farbe++;
			}
			else if(farbe == 1){
				farbe++;
			}
			else if(farbe == 2) {
				cout &lt;&lt; farbe &lt;&lt; endl;
				farbe = 0;
			}
			getline(input, in);
			continue;
		}
	}
	///Close the input-stream
	input.close();
	///Pipe the values into the file
	f.open(&quot;red_histogram.dat&quot;, ios::out);
	for (int j = 0; red[j] != -1; j++) {
		cout &lt;&lt; j &lt;&lt; &quot; &quot; &lt;&lt; red[j] &lt;&lt; endl;
		f &lt;&lt; j &lt;&lt; &quot; &quot; &lt;&lt; red[j] &lt;&lt; endl;
	}
	f.close();
	return NULL;
}
</code></pre>
<p>Ich hoffe irgendwer sieht den Fehler.</p>
<p>Liebe Grüße</p>
<p>René</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1843787</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1843787</guid><dc:creator><![CDATA[rwesterh]]></dc:creator><pubDate>Sat, 23 Jan 2010 16:33:12 GMT</pubDate></item><item><title><![CDATA[Reply to Alles was nach while Schleife kommt nicht beachtet... on Sat, 23 Jan 2010 17:06:00 GMT]]></title><description><![CDATA[<p>Bist du schon mit dem Debugger durch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1843795</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1843795</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Sat, 23 Jan 2010 17:06:00 GMT</pubDate></item><item><title><![CDATA[Reply to Alles was nach while Schleife kommt nicht beachtet... on Sat, 23 Jan 2010 17:26:18 GMT]]></title><description><![CDATA[<p>Hi,<br />
nein, ich weiß nicht wie ich unter Eclipse pthreads zum Laufen bekomme. Diese kommen im Gesamtprogramm vor.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1843805</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1843805</guid><dc:creator><![CDATA[rwesterh]]></dc:creator><pubDate>Sat, 23 Jan 2010 17:26:18 GMT</pubDate></item><item><title><![CDATA[Reply to Alles was nach while Schleife kommt nicht beachtet... on Sat, 23 Jan 2010 17:35:00 GMT]]></title><description><![CDATA[<p>Woher weißt du dann, dass der Teil nach der Schleife übersprungen wird? Zur Not hilft die Holzhammermethode mit Konsolenausgaben um das festzustellen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1843810</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1843810</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Sat, 23 Jan 2010 17:35:00 GMT</pubDate></item><item><title><![CDATA[Reply to Alles was nach while Schleife kommt nicht beachtet... on Sat, 23 Jan 2010 17:43:05 GMT]]></title><description><![CDATA[<p>Ja, in der Konsole habe ich das Programm ja auch schon laufengelassen. Und ich habe mit cout nach der Schleife versucht etwas auszugeben. Aber das wird nicht ausgegeben. Gebe ich hingegen innerhalb der Schleife zum Beispiel die Variable farbe aus, funktioniert es.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1843815</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1843815</guid><dc:creator><![CDATA[rwesterh]]></dc:creator><pubDate>Sat, 23 Jan 2010 17:43:05 GMT</pubDate></item><item><title><![CDATA[Reply to Alles was nach while Schleife kommt nicht beachtet... on Sat, 23 Jan 2010 23:31:13 GMT]]></title><description><![CDATA[<p>ich hab zwar keine Dateien, die da eingelesen werden, aber bei mir bricht das Programm mit einer Exception ab.</p>
<p>Für mich ist unklar was in der Variablen &quot;zahl&quot; drin steht, wodurch dann Speicher für den int reserviert wird. (Wo wird der freigegeben? )</p>
<p>In der for-Schleife hab ich dann teilweise Zugriffsfehler.</p>
<p>Vielleicht zum Testen mal nen Inhalt zur Verfügung stellen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1843913</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1843913</guid><dc:creator><![CDATA[BasicMan01]]></dc:creator><pubDate>Sat, 23 Jan 2010 23:31:13 GMT</pubDate></item></channel></rss>