<?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[Problem bei ifstream]]></title><description><![CDATA[<p>Vollgendes Problem liegt vor und ich komme irgendwie nicht drauf voher das überhaupt kommt:<br />
Hab ein kleines Programm geschrieben um fstream bibliothek auszuprobieren.<br />
In kürze was es tut:<br />
1. es liest eine Datein ein in der nummer pro zeile eine steht und schreibt es nach einer Umwandlung in einen eindimensionalen array. Letzte zahl wird auf 0 gesetzt. Array ist initialisiert umd as vorwegzunehmen.(funkt auch mit atoi).<br />
2. eine weitere Datei soll eingelsen werden zeichen für zeichen, dabei werden ein paar Zeichen rausgefiltert (was kein Problem darstellt).<br />
Dieser Vorgang wird so lange wiederholt solange im oben genanntem array 0 auftaucht:</p>
<pre><code class="language-cpp">ifstream trainer;
	int  count=0, s=0; 
	input.open(&quot;input.sql&quot;, ios::in | ios::binary);
	ofstream final;
	char c;
	final.open(&quot;output.sql&quot;, ios::out | ios::binary);
	while(array_int[s]!=0) // tut solange bis eine Null aufgetroffen wird.
	{
		while (!input.eof()) 
		{
			c=input.get();
			if (int(c)==int('('))  // &lt;-- Anfang vom filter
			{
				count++;
				final.put(c);
			} else if (count == 2)
			{
				final.put(array_int[s]);
				count=0;
			} else 
			{
				final.put(c);
			} // &lt;-- Ende vom filter.
		}
		s++;
		input.seekg(0, ios::beg); //&lt;-- sollte an den anfang von iput.sql gehen, bezweifle das es funktioniert.
	}
	/********/
	// close
	flush(final);
	final.close();
	trainer.close();
</code></pre>
<p>Die Eingabe wird nur ein mal in die datei geschrieben trotz mehrer Zahlen im array vor der 0.<br />
Der Inhalt der Datei in die geschrieben wird hat seltsame Zeichen am Ende</p>
<blockquote>
<p>ÿÿ</p>
</blockquote>
<p>. Mehr Zeichen tauchen auf um so mehr Zahlen im array stehen.</p>
<p>Würde mich freuen, wenn jemand mir das Problem erklären würde bzw. eine Lösung anbieten würde.<br />
Warscheinlich sehe ich mal wieder den Wald vor lauter Bäumen nicht.</p>
<p>Vielen Dank schon mal im Voraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/247688/problem-bei-ifstream</link><generator>RSS for Node</generator><lastBuildDate>Thu, 17 Sep 2026 11:29:51 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/247688.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 14 Aug 2009 09:43:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem bei ifstream on Fri, 14 Aug 2009 09:45:57 GMT]]></title><description><![CDATA[<p>Vollgendes Problem liegt vor und ich komme irgendwie nicht drauf voher das überhaupt kommt:<br />
Hab ein kleines Programm geschrieben um fstream bibliothek auszuprobieren.<br />
In kürze was es tut:<br />
1. es liest eine Datein ein in der nummer pro zeile eine steht und schreibt es nach einer Umwandlung in einen eindimensionalen array. Letzte zahl wird auf 0 gesetzt. Array ist initialisiert umd as vorwegzunehmen.(funkt auch mit atoi).<br />
2. eine weitere Datei soll eingelsen werden zeichen für zeichen, dabei werden ein paar Zeichen rausgefiltert (was kein Problem darstellt).<br />
Dieser Vorgang wird so lange wiederholt solange im oben genanntem array 0 auftaucht:</p>
<pre><code class="language-cpp">ifstream trainer;
	int  count=0, s=0; 
	input.open(&quot;input.sql&quot;, ios::in | ios::binary);
	ofstream final;
	char c;
	final.open(&quot;output.sql&quot;, ios::out | ios::binary);
	while(array_int[s]!=0) // tut solange bis eine Null aufgetroffen wird.
	{
		while (!input.eof()) 
		{
			c=input.get();
			if (int(c)==int('('))  // &lt;-- Anfang vom filter
			{
				count++;
				final.put(c);
			} else if (count == 2)
			{
				final.put(array_int[s]);
				count=0;
			} else 
			{
				final.put(c);
			} // &lt;-- Ende vom filter.
		}
		s++;
		input.seekg(0, ios::beg); //&lt;-- sollte an den anfang von iput.sql gehen, bezweifle das es funktioniert.
	}
	/********/
	// close
	flush(final);
	final.close();
	trainer.close();
</code></pre>
<p>Die Eingabe wird nur ein mal in die datei geschrieben trotz mehrer Zahlen im array vor der 0.<br />
Der Inhalt der Datei in die geschrieben wird hat seltsame Zeichen am Ende</p>
<blockquote>
<p>ÿÿ</p>
</blockquote>
<p>. Mehr Zeichen tauchen auf um so mehr Zahlen im array stehen.</p>
<p>Würde mich freuen, wenn jemand mir das Problem erklären würde bzw. eine Lösung anbieten würde.<br />
Warscheinlich sehe ich mal wieder den Wald vor lauter Bäumen nicht.</p>
<p>Vielen Dank schon mal im Voraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760594</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760594</guid><dc:creator><![CDATA[crackm]]></dc:creator><pubDate>Fri, 14 Aug 2009 09:45:57 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei ifstream on Fri, 14 Aug 2009 09:49:11 GMT]]></title><description><![CDATA[<p>Aus welchem Buch hast Du diesen Stil mit dem open und close?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760598</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760598</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Fri, 14 Aug 2009 09:49:11 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei ifstream on Fri, 14 Aug 2009 09:53:28 GMT]]></title><description><![CDATA[<p>C++ Referenz von Franzis aber es scheint nicht das Problem zu sein, da das öffnen funktioniert und Compilerfehler gibts auch nicht.<br />
Ich weiß man könnte noch:</p>
<pre><code class="language-cpp">final.open(&quot;output.sql&quot;, ios::out, ios::binary);
</code></pre>
<p>Spielt aber keine Rolle in so fern. Glaub ich zu mindest.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760604</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760604</guid><dc:creator><![CDATA[crackm]]></dc:creator><pubDate>Fri, 14 Aug 2009 09:53:28 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei ifstream on Fri, 14 Aug 2009 09:57:54 GMT]]></title><description><![CDATA[<p>crackm schrieb:</p>
<blockquote>
<p>C++ Referenz von Franzis</p>
</blockquote>
<p>Danke.</p>
<p>crackm schrieb:</p>
<blockquote>
<p>Ich weiß man könnte noch:</p>
<pre><code class="language-cpp">final.open(&quot;output.sql&quot;, ios::out, ios::binary);
</code></pre>
<p>Spielt aber keine Rolle in so fern. Glaub ich zu mindest.</p>
</blockquote>
<p>Eher</p>
<pre><code class="language-cpp">ofstream final(&quot;output.sql&quot;,ios::binary);
</code></pre>
<p>und niemals open und close verwenden.<br />
Spielt aber zu Deiner Frage keine Rolle, es war nur, damit ich das Buch abhaken kann. Aber es hatte den Haken schon.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760607</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760607</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Fri, 14 Aug 2009 09:57:54 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei ifstream on Fri, 14 Aug 2009 10:00:15 GMT]]></title><description><![CDATA[<p>Zugriffsrechte werden dann garnicht gesetzt oder wie ?<br />
Ist es dafault ios::in?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760609</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760609</guid><dc:creator><![CDATA[crackm]]></dc:creator><pubDate>Fri, 14 Aug 2009 10:00:15 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei ifstream on Fri, 14 Aug 2009 10:01:34 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>[...] und niemals open und close verwenden.</p>
</blockquote>
<p>Jetzt frage ich mich, was dagegen spricht. Ich habe das auch so gelernt, benutze es aber aus Schreibfaulheit nur selten. Bitte um Aufklärung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760611</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760611</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 14 Aug 2009 10:01:34 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei ifstream on Fri, 14 Aug 2009 10:07:38 GMT]]></title><description><![CDATA[<p>löscht seekg das eof-flag?<br />
<a href="http://www.codeguru.com/forum/archive/index.php/t-271372.html" rel="nofollow">http://www.codeguru.com/forum/archive/index.php/t-271372.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760613</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760613</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Fri, 14 Aug 2009 10:07:38 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei ifstream on Fri, 14 Aug 2009 10:03:56 GMT]]></title><description><![CDATA[<p>crackm schrieb:</p>
<blockquote>
<p>Zugriffsrechte werden dann garnicht gesetzt oder wie ?<br />
Ist es dafault ios::in?</p>
</blockquote>
<p>unterschiedlich!<br />
bei ifstream ist es ios::in und bei ofstream ist es ios::out. also man kann sie ignorieren, es klappt von allein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760615</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760615</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Fri, 14 Aug 2009 10:03:56 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei ifstream on Fri, 14 Aug 2009 10:06:26 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>löscht seekg das eof-flag?</p>
</blockquote>
<p>Es sollte oder zumindest beabsichtige ich es, aber ob es passiert kann man ja kaum überprüfen, d.h. habe ich ja rangeschrieben, dass ich bezweifle das es funktioniert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760616</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760616</guid><dc:creator><![CDATA[crackm]]></dc:creator><pubDate>Fri, 14 Aug 2009 10:06:26 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei ifstream on Fri, 14 Aug 2009 10:06:42 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>crackm schrieb:</p>
<blockquote>
<p>Zugriffsrechte werden dann garnicht gesetzt oder wie ?<br />
Ist es dafault ios::in?</p>
</blockquote>
<p>unterschiedlich!<br />
bei ifstream ist es ios::in und bei ofstream ist es ios::out. also man kann sie ignorieren, es klappt von allein.</p>
</blockquote>
<p>außer den zwei modi gibts noch mehr ios::app zum Beispiel, ist nebenbei gesagt sehr nützlich.<br />
Aber es tut hier nnix zur Sache.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760619</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760619</guid><dc:creator><![CDATA[crackm]]></dc:creator><pubDate>Fri, 14 Aug 2009 10:06:42 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei ifstream on Fri, 14 Aug 2009 10:08:57 GMT]]></title><description><![CDATA[<p>crackm schrieb:</p>
<blockquote>
<p>außer den zwei modi gibts noch mehr ios::app zum Beispiel, ist nebenbei gesagt sehr nützlich.<br />
Aber es tut hier nnix zur Sache.</p>
</blockquote>
<p>Ja, ios::app ist das einzige, was ich benutze.<br />
Hab im Post um 12:02 einen Link zugefügt, wo andere das gleiche Problem hatten und lösten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760623</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760623</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Fri, 14 Aug 2009 10:08:57 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei ifstream on Fri, 14 Aug 2009 10:26:35 GMT]]></title><description><![CDATA[<p>nein, das Problem bei ihm sieht zwar oberflächlich ähnlich aus, hab aber andere Ursachen, wie !Obj.eof() un ähnliches, hilft mir d.h. nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760647</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760647</guid><dc:creator><![CDATA[crackm]]></dc:creator><pubDate>Fri, 14 Aug 2009 10:26:35 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei ifstream on Fri, 14 Aug 2009 10:38:37 GMT]]></title><description><![CDATA[<p>Wie wärs denn mal mit Debuggen? Und kannst ja vielleicht mal den Source und die Dateien online stellen, damit wir uns das genauer angucken können. Und warum benutzt du keine for Schleife? Sticht sofort ins Auge.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760658</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760658</guid><dc:creator><![CDATA[-insane- 0]]></dc:creator><pubDate>Fri, 14 Aug 2009 10:38:37 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei ifstream on Fri, 14 Aug 2009 10:55:17 GMT]]></title><description><![CDATA[<p>Source welche Probleme macht steht im ersten Post der Rest funktioniert.<br />
Der Inhalt der einzulesenen Datei:</p>
<pre><code>insert into beg (entry, id, key) VALUES (31, 21, 25864);
insert into beg (entry, id, key) VALUES (31, 23, 25864);
</code></pre>
<p>Die Liste der Zahlen tut aber auch nicht zur Sache:</p>
<blockquote>
<p>1<br />
2</p>
</blockquote>
<p>For-Schleife haben den Nachteil das die Angaben schon vor der Ausführung fest stehen sollten, dass ist aber nicht der Fall.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760673</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760673</guid><dc:creator><![CDATA[crackm]]></dc:creator><pubDate>Fri, 14 Aug 2009 10:55:17 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei ifstream on Fri, 14 Aug 2009 11:01:31 GMT]]></title><description><![CDATA[<p>crackm schrieb:</p>
<blockquote>
<p>nein, das Problem bei ihm sieht zwar oberflächlich ähnlich aus, hab aber andere Ursachen, wie !Obj.eof() un ähnliches, hilft mir d.h. nicht.</p>
</blockquote>
<p>Ups, dann hab ich wohl falsch gelesen, ich dachte, er hätte genau wie Du clear() vor seekg() vergessen, weshalb der stream noch im eof-ich-tue-nix-mehr-modus war und auch nicht seekgte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760680</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760680</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Fri, 14 Aug 2009 11:01:31 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei ifstream on Fri, 14 Aug 2009 11:19:49 GMT]]></title><description><![CDATA[<p>Vielleicht fehlt der NULL Terminator am Ende der Datei?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760701</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760701</guid><dc:creator><![CDATA[-insane- 0]]></dc:creator><pubDate>Fri, 14 Aug 2009 11:19:49 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei ifstream on Fri, 14 Aug 2009 11:24:41 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>crackm schrieb:</p>
<blockquote>
<p>nein, das Problem bei ihm sieht zwar oberflächlich ähnlich aus, hab aber andere Ursachen, wie !Obj.eof() un ähnliches, hilft mir d.h. nicht.</p>
</blockquote>
<p>Ups, dann hab ich wohl falsch gelesen, ich dachte, er hätte genau wie Du clear() vor seekg() vergessen, weshalb der stream noch im eof-ich-tue-nix-mehr-modus war und auch nicht seekgte.</p>
</blockquote>
<p>Ups das habe ich überlesen, ja ich habe auch clear vergessen, jetzt stimmt die Anzahl der Ausgaben. Thx, denn Rest schaffe ich allein. Kann geschloßen werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760703</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760703</guid><dc:creator><![CDATA[crackm]]></dc:creator><pubDate>Fri, 14 Aug 2009 11:24:41 GMT</pubDate></item></channel></rss>