<?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[Dateiausgabe als txt]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte Ausgabe meiner Datei in einer Txt File speichern. Wenn ich einen String schreibe, dann klappt alles, aber ich mochte eine Tabelle ausgeben.<br />
vielleicht kann mir jemand helfen.<br />
</p>
<pre><code class="language-cpp">#include &lt;fstream&gt;
#include &lt;string&gt; 
#include &lt;vector&gt;

#include &lt;iostream&gt;

using namespace std;

void funktion()
{  
     vector&lt;double&gt; kosten(12); 

    for(size_t i = 0; i &lt; kosten.size(); ++i) {
        kosten[i] = (150-i*i)/10.0;
    }

    // Tabelle ausgeben
    for(size_t i = 0; i &lt; kosten.size(); ++i) {
        cout &lt;&lt; i &lt;&lt; &quot;: &quot; &lt;&lt; kosten[i] &lt;&lt; endl;
    }
 }
int _tmain(int argc, _TCHAR* argv[])
{
   funktion();
    fstream myFile;
    myFile.open(&quot;n.txt&quot;, ios::out);
    myFile &lt;&lt; funktion() &lt;&lt; '\n';
    myFile.close();

   char ch;
   cin &gt;&gt; ch;

	return 0;
}
</code></pre>
<p>danke euch!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/246993/dateiausgabe-als-txt</link><generator>RSS for Node</generator><lastBuildDate>Thu, 17 Sep 2026 19:25:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/246993.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 04 Aug 2009 17:30:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dateiausgabe als txt on Tue, 04 Aug 2009 17:30:31 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte Ausgabe meiner Datei in einer Txt File speichern. Wenn ich einen String schreibe, dann klappt alles, aber ich mochte eine Tabelle ausgeben.<br />
vielleicht kann mir jemand helfen.<br />
</p>
<pre><code class="language-cpp">#include &lt;fstream&gt;
#include &lt;string&gt; 
#include &lt;vector&gt;

#include &lt;iostream&gt;

using namespace std;

void funktion()
{  
     vector&lt;double&gt; kosten(12); 

    for(size_t i = 0; i &lt; kosten.size(); ++i) {
        kosten[i] = (150-i*i)/10.0;
    }

    // Tabelle ausgeben
    for(size_t i = 0; i &lt; kosten.size(); ++i) {
        cout &lt;&lt; i &lt;&lt; &quot;: &quot; &lt;&lt; kosten[i] &lt;&lt; endl;
    }
 }
int _tmain(int argc, _TCHAR* argv[])
{
   funktion();
    fstream myFile;
    myFile.open(&quot;n.txt&quot;, ios::out);
    myFile &lt;&lt; funktion() &lt;&lt; '\n';
    myFile.close();

   char ch;
   cin &gt;&gt; ch;

	return 0;
}
</code></pre>
<p>danke euch!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1755235</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1755235</guid><dc:creator><![CDATA[pi]]></dc:creator><pubDate>Tue, 04 Aug 2009 17:30:31 GMT</pubDate></item><item><title><![CDATA[Reply to Dateiausgabe als txt on Tue, 04 Aug 2009 17:36:35 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">// ...
#include &lt;sstream&gt;

std::string funktion()
{
	vector&lt;double&gt; kosten(12);
	std::string tmp;

    for(size_t i = 0; i &lt; kosten.size(); ++i) {
        kosten[i] = (150-i*i)/10.0;
    }

    for(size_t i = 0; i &lt; kosten.size(); ++i) {
		std::stringstream strm;
		strm &lt;&lt; i &lt;&lt; &quot;: &quot; &lt;&lt; kosten[i] &lt;&lt; endl;
		tmp += strm.str();
    }

	return tmp;
}

// ...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1755240</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1755240</guid><dc:creator><![CDATA[BBBB]]></dc:creator><pubDate>Tue, 04 Aug 2009 17:36:35 GMT</pubDate></item><item><title><![CDATA[Reply to Dateiausgabe als txt on Tue, 04 Aug 2009 18:00:19 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iomanip&gt; // std::setw
#include &lt;fstream&gt;
#include &lt;vector&gt;

#include &lt;cstddef&gt; // std::size_t

template &lt;typename Container&gt;
void tableWriter(std::ostream&amp; os, const Container&amp; con)
{
	std::size_t counter(0);
	std::size_t size(con.size());
	std::size_t width(0);
	while(size != 0) {
		size /= 10;
		++width;
	}
	for(typename Container::const_iterator beg(con.begin()), end(con.end()); beg != end; ++beg)
		os &lt;&lt; std::setw(width) &lt;&lt; counter++ &lt;&lt; &quot;: &quot; &lt;&lt; *beg &lt;&lt; &quot;\n&quot;;
}

int main()
{
	const std::vector&lt;double&gt;::size_type anzahl(25);
	std::vector&lt;double&gt; kosten;

	for(std::vector&lt;double&gt;::size_type i(0); i != anzahl; ++i)
		kosten.push_back((150 - i * i) / 10.0);

	std::ofstream file_out(&quot;kostentabelle.txt&quot;);
	tableWriter(file_out, kosten);

	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1755255</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1755255</guid><dc:creator><![CDATA[LP @ Ferropolis]]></dc:creator><pubDate>Tue, 04 Aug 2009 18:00:19 GMT</pubDate></item><item><title><![CDATA[Reply to Dateiausgabe als txt on Tue, 04 Aug 2009 19:26:40 GMT]]></title><description><![CDATA[<p>hallo,</p>
<p>ich habe beide vorschläge ausprobiert und beide funktionieren prima. danke für die Hilfe.</p>
<p>Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1755326</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1755326</guid><dc:creator><![CDATA[pi]]></dc:creator><pubDate>Tue, 04 Aug 2009 19:26:40 GMT</pubDate></item></channel></rss>