<?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[Werte in Datei abschpeichern]]></title><description><![CDATA[<p>Hallo, ich habe 4 Vektoren mit Daten(Zahlen). Wie kann ich sie alle nacheinander spaltenweise in eine Datei jeweils mit 10 Nachkommastellen ausgeben? Sie müssen nebeneinander stehen, damit ich das plotten kann.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/314384/werte-in-datei-abschpeichern</link><generator>RSS for Node</generator><lastBuildDate>Sat, 01 Aug 2026 09:48:29 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/314384.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 28 Feb 2013 21:10:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Werte in Datei abschpeichern on Thu, 28 Feb 2013 21:10:34 GMT]]></title><description><![CDATA[<p>Hallo, ich habe 4 Vektoren mit Daten(Zahlen). Wie kann ich sie alle nacheinander spaltenweise in eine Datei jeweils mit 10 Nachkommastellen ausgeben? Sie müssen nebeneinander stehen, damit ich das plotten kann.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303080</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303080</guid><dc:creator><![CDATA[Namal]]></dc:creator><pubDate>Thu, 28 Feb 2013 21:10:34 GMT</pubDate></item><item><title><![CDATA[Reply to Werte in Datei abschpeichern on Thu, 28 Feb 2013 21:18:13 GMT]]></title><description><![CDATA[<p>müsste ungefähr so gehn:</p>
<pre><code class="language-cpp">vector&lt;double&gt; v1, v2, v3;
ofstream ofs(&quot;daten.txt&quot;);
ofs.precision(10);
//annahme: alle vektoren haben gleich viel daten
for(size_t i = 0; i &lt; v1.size(); ++i)
{
  ofs &lt;&lt; v1[i] &lt;&lt; ' ' &lt;&lt; v2[i] &lt;&lt; ' ' &lt;&lt; v3[i] &lt;&lt; endl;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2303087</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303087</guid><dc:creator><![CDATA[*Q* 1]]></dc:creator><pubDate>Thu, 28 Feb 2013 21:18:13 GMT</pubDate></item><item><title><![CDATA[Reply to Werte in Datei abschpeichern on Thu, 28 Feb 2013 21:26:15 GMT]]></title><description><![CDATA[<p>uns was muss ich in dem header einbinden fstream?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303091</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303091</guid><dc:creator><![CDATA[Namal]]></dc:creator><pubDate>Thu, 28 Feb 2013 21:26:15 GMT</pubDate></item><item><title><![CDATA[Reply to Werte in Datei abschpeichern on Thu, 28 Feb 2013 21:30:07 GMT]]></title><description><![CDATA[<p>&lt;fstream&gt;<br />
und<br />
&lt;vector&gt;</p>
<p>und using namespace std; sollte noch irgendwo hin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303092</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303092</guid><dc:creator><![CDATA[*Q* 1]]></dc:creator><pubDate>Thu, 28 Feb 2013 21:30:07 GMT</pubDate></item><item><title><![CDATA[Reply to Werte in Datei abschpeichern on Thu, 28 Feb 2013 23:25:31 GMT]]></title><description><![CDATA[<p>Kan man das auch ausgerichtet ausgeben? Dass die ersten Ziffern immer untereinander sind?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303143</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303143</guid><dc:creator><![CDATA[Namal]]></dc:creator><pubDate>Thu, 28 Feb 2013 23:25:31 GMT</pubDate></item><item><title><![CDATA[Reply to Werte in Datei abschpeichern on Fri, 01 Mar 2013 07:30:05 GMT]]></title><description><![CDATA[<p>Ja, dafür gibt es die IO-Flags wie width, precision usw.</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;vector&gt;
#include &lt;algorithm&gt;
#include &lt;iterator&gt;
#include &lt;ctime&gt;

using std::vector;
using std::ofstream;
using std::endl;

int main()
{
	srand(time(0));
	vector&lt;double&gt; v1, v2, v3, v4;

	std::generate_n(std::back_inserter(v1), rand()%100, rand);
	std::generate_n(std::back_inserter(v2), rand()%100, rand);
	std::generate_n(std::back_inserter(v3), rand()%100, rand);
	std::generate_n(std::back_inserter(v4), rand()%100, rand);

	ofstream out(&quot;YOURFILE.TXT&quot;);

	std::ostream &amp; of = (true) ? std::cout : out;

	std::size_t index = 0;
	while ( index &lt; v1.size() || index &lt; v2.size() || index &lt; v3.size() || index &lt; v4.size() ) // unschön :(
	{
		of.width(15);
		of.precision(10);

		of &lt;&lt; std::fixed &lt;&lt; std::right &lt;&lt; std::showpos;

		if ( index &lt; v1.size() )
			of &lt;&lt; v1[index] &lt;&lt; &quot; &quot;;
		if ( index &lt; v2.size() )
			of &lt;&lt; v2[index] &lt;&lt; &quot; &quot;;
		if ( index &lt; v3.size() )
			of &lt;&lt; v3[index] &lt;&lt; &quot; &quot;;
		if ( index &lt; v4.size() )
			of &lt;&lt; v4[index];

		of &lt;&lt; endl;
	}

	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2303178</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303178</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Fri, 01 Mar 2013 07:30:05 GMT</pubDate></item><item><title><![CDATA[Reply to Werte in Datei abschpeichern on Sat, 02 Mar 2013 17:21:22 GMT]]></title><description><![CDATA[<p>das ding stürzt leider ab</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303630</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303630</guid><dc:creator><![CDATA[Namal]]></dc:creator><pubDate>Sat, 02 Mar 2013 17:21:22 GMT</pubDate></item><item><title><![CDATA[Reply to Werte in Datei abschpeichern on Sat, 02 Mar 2013 17:28:16 GMT]]></title><description><![CDATA[<p>Ja, die || im Schleifenkopf müssen &amp;&amp; sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303632</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303632</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Sat, 02 Mar 2013 17:28:16 GMT</pubDate></item></channel></rss>