<?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[Probleme mit fstream]]></title><description><![CDATA[<p>Hallo alle zusammen. Ich (Anfänger im Programmieren) habe ein Problem mit fstreams. Ich benutze MS Visual Studio 2005.</p>
<p>Also folgende Situation:<br />
Ich möchte aus einer .txt-Datei eine Tabelle in ein Array laden. Die Tabelle besteht aus 87 Spalten und 3000 Zeilen. Die Werte sind einfache Zahlen (ohne Nachkommastelle und ca.&lt;4000). Die Spalten sind getrennt durch ein Leerzeichen.</p>
<p>So nun zu meinem Problem:<br />
Mit dem nachstehenden Code bekomme ich einen &quot;stack overflow&quot;.<br />
Setzte ich const int spalten = 86 steht an jeder Stelle der ausgegebene .txt-Datei die Zahl: -858993460.<br />
Setzte ich const in spalten = 85 erhalte ich eine Tabelle in der .txt-Datei mit einen entsprechendem Versatz der Spalten (alles um 2 Spalten verschoben).<br />
Wo liegt denn jetzt ein Fehler vor?</p>
<p>Der Code:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
using namespace std;

int main(int argc, char **argv)
{	
	const int spalten=87;
	const int zeilen=3000;
	int matrix[spalten][zeilen];
	ifstream fileInput;
	ofstream fileOutput;
	fileInput.open(&quot;C:\\AmpMat5000_B0R.txt&quot;); //einzuladende Tabelle
	fileOutput.open(&quot;C:\\testfuerofstream.txt&quot;); // auszugebende Tabelle
	for (int i=0; i&lt;zeilen; i++)
	{
		for (int k=0; k&lt;spalten; k++)
		{
			fileInput &gt;&gt; (matrix[k][i]);
		}
	}

	//fileInput.close();
	for (int i=0; i&lt;zeilen; i++)
		{
			for (int k=0; k&lt;spalten; k++)
			{
				//cout &lt;&lt; matrix[k][i] &lt;&lt; &quot; &quot;;
				fileOutput &lt;&lt; matrix[k][i] &lt;&lt; &quot; &quot;;
			}
			fileOutput &lt;&lt; endl;
			//cout &lt;&lt; endl;
		}
	fileInput.close();
	fileOutput.close();	

	cout &lt;&lt; endl;

	system(&quot;PAUSE&quot;);
	return 0;

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/196381/probleme-mit-fstream</link><generator>RSS for Node</generator><lastBuildDate>Wed, 30 Sep 2026 18:59:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/196381.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 29 Oct 2007 07:24:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Probleme mit fstream on Mon, 29 Oct 2007 07:24:09 GMT]]></title><description><![CDATA[<p>Hallo alle zusammen. Ich (Anfänger im Programmieren) habe ein Problem mit fstreams. Ich benutze MS Visual Studio 2005.</p>
<p>Also folgende Situation:<br />
Ich möchte aus einer .txt-Datei eine Tabelle in ein Array laden. Die Tabelle besteht aus 87 Spalten und 3000 Zeilen. Die Werte sind einfache Zahlen (ohne Nachkommastelle und ca.&lt;4000). Die Spalten sind getrennt durch ein Leerzeichen.</p>
<p>So nun zu meinem Problem:<br />
Mit dem nachstehenden Code bekomme ich einen &quot;stack overflow&quot;.<br />
Setzte ich const int spalten = 86 steht an jeder Stelle der ausgegebene .txt-Datei die Zahl: -858993460.<br />
Setzte ich const in spalten = 85 erhalte ich eine Tabelle in der .txt-Datei mit einen entsprechendem Versatz der Spalten (alles um 2 Spalten verschoben).<br />
Wo liegt denn jetzt ein Fehler vor?</p>
<p>Der Code:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
using namespace std;

int main(int argc, char **argv)
{	
	const int spalten=87;
	const int zeilen=3000;
	int matrix[spalten][zeilen];
	ifstream fileInput;
	ofstream fileOutput;
	fileInput.open(&quot;C:\\AmpMat5000_B0R.txt&quot;); //einzuladende Tabelle
	fileOutput.open(&quot;C:\\testfuerofstream.txt&quot;); // auszugebende Tabelle
	for (int i=0; i&lt;zeilen; i++)
	{
		for (int k=0; k&lt;spalten; k++)
		{
			fileInput &gt;&gt; (matrix[k][i]);
		}
	}

	//fileInput.close();
	for (int i=0; i&lt;zeilen; i++)
		{
			for (int k=0; k&lt;spalten; k++)
			{
				//cout &lt;&lt; matrix[k][i] &lt;&lt; &quot; &quot;;
				fileOutput &lt;&lt; matrix[k][i] &lt;&lt; &quot; &quot;;
			}
			fileOutput &lt;&lt; endl;
			//cout &lt;&lt; endl;
		}
	fileInput.close();
	fileOutput.close();	

	cout &lt;&lt; endl;

	system(&quot;PAUSE&quot;);
	return 0;

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1393923</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1393923</guid><dc:creator><![CDATA[xchrisx]]></dc:creator><pubDate>Mon, 29 Oct 2007 07:24:09 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit fstream on Mon, 29 Oct 2007 08:27:16 GMT]]></title><description><![CDATA[<p>der stackoverflow kommt wahrscheinlich von dem großen array. machs mit new oder std::vector</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1393941</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1393941</guid><dc:creator><![CDATA[möbel]]></dc:creator><pubDate>Mon, 29 Oct 2007 08:27:16 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit fstream on Mon, 29 Oct 2007 10:40:04 GMT]]></title><description><![CDATA[<p>also das array im heap initialisieren? hatte ich mir auch schon gedacht. jedoch noch nicht probiert. werde ich nachher mal machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1394019</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1394019</guid><dc:creator><![CDATA[xchrisx]]></dc:creator><pubDate>Mon, 29 Oct 2007 10:40:04 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit fstream on Tue, 30 Oct 2007 09:22:50 GMT]]></title><description><![CDATA[<p>wenn das array im heap geladen wird, ist immer noch ein fehler vorhanden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1394526</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1394526</guid><dc:creator><![CDATA[xchrisx]]></dc:creator><pubDate>Tue, 30 Oct 2007 09:22:50 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit fstream on Tue, 30 Oct 2007 09:27:39 GMT]]></title><description><![CDATA[<p>xchrisx schrieb:</p>
<blockquote>
<p>wenn das array im heap geladen wird, ist immer noch ein fehler vorhanden.</p>
</blockquote>
<p><strong>Ein</strong> Fehler oder <strong>derselbe</strong> Fehler?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1394531</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1394531</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Tue, 30 Oct 2007 09:27:39 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit fstream on Tue, 30 Oct 2007 09:43:18 GMT]]></title><description><![CDATA[<p>Eine einfache Matrix-Implementierung, bei der die Daten auf dem Heap liegen, findest Du <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-136483-and-postdays-is-0-and-postorder-is-asc-and-highlight-is-matrix-and-start-is-10.html" rel="nofollow">hier</a>.</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1394541</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1394541</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Tue, 30 Oct 2007 09:43:18 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit fstream on Tue, 30 Oct 2007 11:05:54 GMT]]></title><description><![CDATA[<p>LordJaxom schrieb:</p>
<blockquote>
<p>xchrisx schrieb:</p>
<blockquote>
<p>wenn das array im heap geladen wird, ist immer noch ein fehler vorhanden.</p>
</blockquote>
<p><strong>Ein</strong> Fehler oder <strong>derselbe</strong> Fehler?</p>
</blockquote>
<p>ein anderer:<br />
First-chance exception at 0x104c2315 (msvcp80d.dll) in testings.exe: 0xC0000005: Access violation writing location 0x009fa000.<br />
Unhandled exception at 0x104c2315 (msvcp80d.dll) in testings.exe: 0xC0000005: Access violation writing location 0x009fa000.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1394600</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1394600</guid><dc:creator><![CDATA[xchrisx]]></dc:creator><pubDate>Tue, 30 Oct 2007 11:05:54 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit fstream on Tue, 30 Oct 2007 11:20:21 GMT]]></title><description><![CDATA[<p>Dann debugge doch einfach den Code und schau dir an wo es knallt (auch wenn die Fehlerursache meist vorher liegt).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1394608</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1394608</guid><dc:creator><![CDATA[Th]]></dc:creator><pubDate>Tue, 30 Oct 2007 11:20:21 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit fstream on Sun, 04 Nov 2007 18:47:37 GMT]]></title><description><![CDATA[<p>so ich habe meinen Fehler gefunden.<br />
es klappt wenn ich das array mit &quot;new&quot; im heap alloziere.<br />
ich hatte nur das array in meiner klasse(wovon ich dann das objekt im heap alloziert heap) zu klein gewählt ([85][3000] anstatt [87][3000])<br />
aber vielen dank für eure mithilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397685</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397685</guid><dc:creator><![CDATA[xchrisx]]></dc:creator><pubDate>Sun, 04 Nov 2007 18:47:37 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit fstream on Sun, 04 Nov 2007 21:11:42 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;
// #include &lt;cstdlib&gt;
// #include &lt;cstdio&gt;
// #include &lt;cstring&gt;
</code></pre>
<p>und</p>
<pre><code class="language-cpp">// std::system(&quot;PAUSE&quot;);
/* falls nötig
std::cin.clear();
std::cin.ignore(std::numeric_limits&lt;std::streamsize&gt;::max(), '\n');
*/
std::cin.get();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1397774</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397774</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Sun, 04 Nov 2007 21:11:42 GMT</pubDate></item></channel></rss>