<?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[Standartausgabe cout, ich möchte cout lesen in c hab ich einfach]]></title><description><![CDATA[<p>Guten Tag,</p>
<p>ich habe ein kleines Problem, habe eine Ausgabe, die ich einmal am Bildschirm haben möchte, also std::cout &lt;&lt; ... und einmal in eine Datei schreiben muß.</p>
<p>outf(filename.c_str(), std::ios_base::out | std::ios_base::app);<br />
230<br />
231 if(outf)</p>
<p>ist im Prinzip kein wirklich großes Problem mehrere Methoden mit gleichem Inhalt zu schreiben, aber ich würde doch lieber den &quot;Zeiger&quot; auf das Objekt mitgeben in dem die Ausgabe geschehen soll und das dann mit der gleichen Funktion bearbeiten lassen....</p>
<p>fstream(std::cout) haut nicht hin, krieg ich folgende fehlermeldung:</p>
<p><a href="http://probieren.cc" rel="nofollow">probieren.cc</a> -o soso<br />
In file included from /usr/include/c++/4.4/ios:39,<br />
from /usr/include/c++/4.4/ostream:40,<br />
from /usr/include/c++/4.4/iostream:40,<br />
from <a href="http://probieren.cc:1" rel="nofollow">probieren.cc:1</a>:<br />
/usr/include/c++/4.4/bits/ios_base.h: In copy constructor ‘std::basic_ios&lt;char, std::char_traits&lt;char&gt; &gt;::basic_ios(const std::basic_ios&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)’:<br />
/usr/include/c++/4.4/bits/ios_base.h:790: error: ‘std::ios_base::ios_base(const std::ios_base&amp;)’ is private<br />
/usr/include/c++/4.4/iosfwd:47: error: within this context<br />
/usr/include/c++/4.4/iosfwd: In copy constructor ‘std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;::basic_ostream(const std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)’:<br />
/usr/include/c++/4.4/iosfwd:56: note: synthesized method ‘std::basic_ios&lt;char, std::char_traits&lt;char&gt; &gt;::basic_ios(const std::basic_ios&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)’ first required here<br />
<a href="http://probieren.cc" rel="nofollow">probieren.cc</a>: In function ‘int main()’:<br />
<a href="http://probieren.cc:8" rel="nofollow">probieren.cc:8</a>: note: synthesized method ‘std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;::basic_ostream(const std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)’ first required here</p>
<p>Jetzt meine Frage, gibts irgendeine Möglich keit den filestream auf cout bzw. cout auf einen filestream zu legen oder muß ich dafür einfach die C-Funktionen benutzen und den Zeiger für stdout und FILE* benutzen???<br />
vielen dank<br />
ks</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/272211/standartausgabe-cout-ich-möchte-cout-lesen-in-c-hab-ich-einfach</link><generator>RSS for Node</generator><lastBuildDate>Sat, 29 Aug 2026 01:03:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/272211.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 12 Aug 2010 18:06:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Standartausgabe cout, ich möchte cout lesen in c hab ich einfach on Thu, 12 Aug 2010 18:06:08 GMT]]></title><description><![CDATA[<p>Guten Tag,</p>
<p>ich habe ein kleines Problem, habe eine Ausgabe, die ich einmal am Bildschirm haben möchte, also std::cout &lt;&lt; ... und einmal in eine Datei schreiben muß.</p>
<p>outf(filename.c_str(), std::ios_base::out | std::ios_base::app);<br />
230<br />
231 if(outf)</p>
<p>ist im Prinzip kein wirklich großes Problem mehrere Methoden mit gleichem Inhalt zu schreiben, aber ich würde doch lieber den &quot;Zeiger&quot; auf das Objekt mitgeben in dem die Ausgabe geschehen soll und das dann mit der gleichen Funktion bearbeiten lassen....</p>
<p>fstream(std::cout) haut nicht hin, krieg ich folgende fehlermeldung:</p>
<p><a href="http://probieren.cc" rel="nofollow">probieren.cc</a> -o soso<br />
In file included from /usr/include/c++/4.4/ios:39,<br />
from /usr/include/c++/4.4/ostream:40,<br />
from /usr/include/c++/4.4/iostream:40,<br />
from <a href="http://probieren.cc:1" rel="nofollow">probieren.cc:1</a>:<br />
/usr/include/c++/4.4/bits/ios_base.h: In copy constructor ‘std::basic_ios&lt;char, std::char_traits&lt;char&gt; &gt;::basic_ios(const std::basic_ios&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)’:<br />
/usr/include/c++/4.4/bits/ios_base.h:790: error: ‘std::ios_base::ios_base(const std::ios_base&amp;)’ is private<br />
/usr/include/c++/4.4/iosfwd:47: error: within this context<br />
/usr/include/c++/4.4/iosfwd: In copy constructor ‘std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;::basic_ostream(const std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)’:<br />
/usr/include/c++/4.4/iosfwd:56: note: synthesized method ‘std::basic_ios&lt;char, std::char_traits&lt;char&gt; &gt;::basic_ios(const std::basic_ios&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)’ first required here<br />
<a href="http://probieren.cc" rel="nofollow">probieren.cc</a>: In function ‘int main()’:<br />
<a href="http://probieren.cc:8" rel="nofollow">probieren.cc:8</a>: note: synthesized method ‘std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;::basic_ostream(const std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)’ first required here</p>
<p>Jetzt meine Frage, gibts irgendeine Möglich keit den filestream auf cout bzw. cout auf einen filestream zu legen oder muß ich dafür einfach die C-Funktionen benutzen und den Zeiger für stdout und FILE* benutzen???<br />
vielen dank<br />
ks</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1939338</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1939338</guid><dc:creator><![CDATA[thepower]]></dc:creator><pubDate>Thu, 12 Aug 2010 18:06:08 GMT</pubDate></item><item><title><![CDATA[Reply to Standartausgabe cout, ich möchte cout lesen in c hab ich einfach on Thu, 12 Aug 2010 18:12:05 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich benutze in einem meiner Programme</p>
<pre><code class="language-cpp">std::ostream&amp; out = (filename != &quot;-&quot;)
			? *(new std::ofstream(filename.c_str()))
			: std::cout;
</code></pre>
<p>Wenn der filename ein Minus ist, dann schreibe ich auf cout, ansonsten öffne ich die Datei.</p>
<p>Gruß,<br />
MJM</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1939342</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1939342</guid><dc:creator><![CDATA[MJM]]></dc:creator><pubDate>Thu, 12 Aug 2010 18:12:05 GMT</pubDate></item><item><title><![CDATA[Reply to Standartausgabe cout, ich möchte cout lesen in c hab ich einfach on Sat, 14 Aug 2010 13:00:20 GMT]]></title><description><![CDATA[<p>Ich schreib in VC++<br />
unf schreibe immer so meine Dateien:</p>
<p>#include &lt;iostream&gt;<br />
using namespace std;</p>
<p>int main() {<br />
cout&lt;&lt;&quot;Der Text den man eben haben will&quot;&lt;&lt;endl;<br />
}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1939954</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1939954</guid><dc:creator><![CDATA[DilBahadur]]></dc:creator><pubDate>Sat, 14 Aug 2010 13:00:20 GMT</pubDate></item><item><title><![CDATA[Reply to Standartausgabe cout, ich möchte cout lesen in c hab ich einfach on Sat, 14 Aug 2010 14:52:31 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">void Write(std::ostream&amp; os, const zeug&amp; meinzeugs)
{
  os &lt;&lt; meinzeugs.a() &lt;&lt; meinzeugs.b() ...;
}

void f()
{
  zeug z;
  //...
  Write(std::cout, z);

  fstream ifs(&quot;file&quot;);
  Write(ifs, z);
}
</code></pre>
<p>War das tatsächlich die Fräge?<br />
Man könnte auch ein <code>template&lt;typename Stream&gt; Write(Stram&amp; s, ...)</code> um in alles was ein <code>&lt;&lt;</code> Operator unterstützt zu schreiben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1939993</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1939993</guid><dc:creator><![CDATA[brotbernd]]></dc:creator><pubDate>Sat, 14 Aug 2010 14:52:31 GMT</pubDate></item></channel></rss>