<?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[.txt Datei mit inhalt erstellen]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe mir einen kleinen Rechner gebastelt, damit ich mir schneller ausrechnen kann wie lange ich für ein neues System sparen müsste.</p>
<p>Der Code ist bis jetzt folgender:</p>
<pre><code class="language-cpp">#include &lt;cstdlib&gt;
#include &lt;iostream&gt;

using namespace std;

int main(int argc, char *argv[])
{
    double aGuthaben, aTaschengeld, aMainboard, bMainboard, aGraka, bGraka, aSound, bSound, aCPU, bCPU, aRAM, bRAM, aDVD, bDVD, aSonstiges, bSonstiges, aMin, aMax, aMonate, bMonate;
    char   aSchleife;

    cout &lt;&lt; endl &lt;&lt; endl &lt;&lt; &quot;  ---| Kostenberechner fuer einen neuen PC |---&quot;
         &lt;&lt; endl &lt;&lt; endl &lt;&lt; &quot;  Mit diesem Programm kannst du berechnen wie lange du&quot;
         &lt;&lt; endl         &lt;&lt; &quot;  auf einen neuen PC sparen musst.&quot;
         &lt;&lt; endl &lt;&lt; endl &lt;&lt; &quot;  Zuerst werden die Kosten fuer die einzelnen Geräte erfasst.&quot;
         &lt;&lt; endl         &lt;&lt; &quot;  Zu jedem Gerät wird ein minimaler und ein maximaler Kosten-&quot;
         &lt;&lt; endl         &lt;&lt; &quot;  Wert erfasst.&quot;;

    cout &lt;&lt; endl &lt;&lt; endl &lt;&lt; &quot;  min. Kosten fuer ein Mainboard: &quot;;        
    cin  &gt;&gt; aMainboard;    
    cout                 &lt;&lt; &quot;                     max. Kosten: &quot;;    
    cin  &gt;&gt; bMainboard;

    cout                 &lt;&lt; &quot;  min. Kosten fuer eine Grafikkarte: &quot;;        
    cin  &gt;&gt; aGraka;    
    cout                 &lt;&lt; &quot;                        max. Kosten: &quot;;    
    cin  &gt;&gt; bGraka;

    cout                 &lt;&lt; &quot;  min. Kosten fuer eine Soundkarte: &quot;;        
    cin  &gt;&gt; aSound;    
    cout                 &lt;&lt; &quot;                       max. Kosten: &quot;;    
    cin  &gt;&gt; bSound;

    cout                 &lt;&lt; &quot;  min. Kosten fuer eine CPU: &quot;;        
    cin  &gt;&gt; aCPU;    
    cout                 &lt;&lt; &quot;                max. Kosten: &quot;;    
    cin  &gt;&gt; bCPU;

    cout                 &lt;&lt; &quot;  min. Kosten fuer Arbeitsspeicher: &quot;;        
    cin  &gt;&gt; aRAM;    
    cout                 &lt;&lt; &quot;                       max. Kosten: &quot;;    
    cin  &gt;&gt; bRAM;

    cout                 &lt;&lt; &quot;  min. Kosten fuer sonstige Geraete/Software: &quot;;        
    cin  &gt;&gt; aSonstiges;    
    cout                 &lt;&lt; &quot;                                 max. Kosten: &quot;;    
    cin  &gt;&gt; bSonstiges;

    cout                 &lt;&lt; &quot;  Ihr monatliches Einkommen (Taschengeld): &quot;;        
    cin  &gt;&gt; aTaschengeld;

    cout                 &lt;&lt; &quot;  Ihr jetziges Budget: &quot;;        
    cin  &gt;&gt; aGuthaben;

    aMin = aMainboard + aGraka + aSound + aCPU + aRAM + aSonstiges;
    aMax = bMainboard + bGraka + bSound + bCPU + bRAM + bSonstiges;    

    aMonate = aMin - aGuthaben;
    aMonate = aMonate / aTaschengeld;

    bMonate = aMax - aGuthaben;
    bMonate = bMonate / aTaschengeld;

    cout &lt;&lt; endl &lt;&lt; endl &lt;&lt; &quot;  ############################################################# &quot;
         &lt;&lt; endl &lt;&lt; endl &lt;&lt; &quot;  Ihr System kostet &quot; &lt;&lt; aMin &lt;&lt; &quot; bis &quot; &lt;&lt; aMax &lt;&lt; &quot; Euro.&quot;
         &lt;&lt; endl         &lt;&lt; &quot;  Sie muessen noch &quot; &lt;&lt; aMonate &lt;&lt; &quot; bis &quot; &lt;&lt; bMonate &lt;&lt; &quot; Monate sparen.&quot;;           

    cout &lt;&lt; endl &lt;&lt; endl &lt;&lt; &quot;  ------------------------------------------------------------- &quot;
         &lt;&lt; endl &lt;&lt; endl &lt;&lt; &quot;  &quot;;
    system(&quot;PAUSE&quot;);
    return EXIT_SUCCESS;
}
</code></pre>
<p>Nun möchte ich noch das das ganze in eine .txt-Datei gespeichert wird. Möglichst in den selben Ordner in der sich die .exe befindet.</p>
<p>Mein C/C++-Wissen übersteigt kaum dem, was man in einem halben Jahr so in der Schule lernt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/171342/txt-datei-mit-inhalt-erstellen</link><generator>RSS for Node</generator><lastBuildDate>Thu, 17 Sep 2026 09:50:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/171342.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 24 Jan 2007 15:46:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to .txt Datei mit inhalt erstellen on Wed, 24 Jan 2007 15:46:07 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe mir einen kleinen Rechner gebastelt, damit ich mir schneller ausrechnen kann wie lange ich für ein neues System sparen müsste.</p>
<p>Der Code ist bis jetzt folgender:</p>
<pre><code class="language-cpp">#include &lt;cstdlib&gt;
#include &lt;iostream&gt;

using namespace std;

int main(int argc, char *argv[])
{
    double aGuthaben, aTaschengeld, aMainboard, bMainboard, aGraka, bGraka, aSound, bSound, aCPU, bCPU, aRAM, bRAM, aDVD, bDVD, aSonstiges, bSonstiges, aMin, aMax, aMonate, bMonate;
    char   aSchleife;

    cout &lt;&lt; endl &lt;&lt; endl &lt;&lt; &quot;  ---| Kostenberechner fuer einen neuen PC |---&quot;
         &lt;&lt; endl &lt;&lt; endl &lt;&lt; &quot;  Mit diesem Programm kannst du berechnen wie lange du&quot;
         &lt;&lt; endl         &lt;&lt; &quot;  auf einen neuen PC sparen musst.&quot;
         &lt;&lt; endl &lt;&lt; endl &lt;&lt; &quot;  Zuerst werden die Kosten fuer die einzelnen Geräte erfasst.&quot;
         &lt;&lt; endl         &lt;&lt; &quot;  Zu jedem Gerät wird ein minimaler und ein maximaler Kosten-&quot;
         &lt;&lt; endl         &lt;&lt; &quot;  Wert erfasst.&quot;;

    cout &lt;&lt; endl &lt;&lt; endl &lt;&lt; &quot;  min. Kosten fuer ein Mainboard: &quot;;        
    cin  &gt;&gt; aMainboard;    
    cout                 &lt;&lt; &quot;                     max. Kosten: &quot;;    
    cin  &gt;&gt; bMainboard;

    cout                 &lt;&lt; &quot;  min. Kosten fuer eine Grafikkarte: &quot;;        
    cin  &gt;&gt; aGraka;    
    cout                 &lt;&lt; &quot;                        max. Kosten: &quot;;    
    cin  &gt;&gt; bGraka;

    cout                 &lt;&lt; &quot;  min. Kosten fuer eine Soundkarte: &quot;;        
    cin  &gt;&gt; aSound;    
    cout                 &lt;&lt; &quot;                       max. Kosten: &quot;;    
    cin  &gt;&gt; bSound;

    cout                 &lt;&lt; &quot;  min. Kosten fuer eine CPU: &quot;;        
    cin  &gt;&gt; aCPU;    
    cout                 &lt;&lt; &quot;                max. Kosten: &quot;;    
    cin  &gt;&gt; bCPU;

    cout                 &lt;&lt; &quot;  min. Kosten fuer Arbeitsspeicher: &quot;;        
    cin  &gt;&gt; aRAM;    
    cout                 &lt;&lt; &quot;                       max. Kosten: &quot;;    
    cin  &gt;&gt; bRAM;

    cout                 &lt;&lt; &quot;  min. Kosten fuer sonstige Geraete/Software: &quot;;        
    cin  &gt;&gt; aSonstiges;    
    cout                 &lt;&lt; &quot;                                 max. Kosten: &quot;;    
    cin  &gt;&gt; bSonstiges;

    cout                 &lt;&lt; &quot;  Ihr monatliches Einkommen (Taschengeld): &quot;;        
    cin  &gt;&gt; aTaschengeld;

    cout                 &lt;&lt; &quot;  Ihr jetziges Budget: &quot;;        
    cin  &gt;&gt; aGuthaben;

    aMin = aMainboard + aGraka + aSound + aCPU + aRAM + aSonstiges;
    aMax = bMainboard + bGraka + bSound + bCPU + bRAM + bSonstiges;    

    aMonate = aMin - aGuthaben;
    aMonate = aMonate / aTaschengeld;

    bMonate = aMax - aGuthaben;
    bMonate = bMonate / aTaschengeld;

    cout &lt;&lt; endl &lt;&lt; endl &lt;&lt; &quot;  ############################################################# &quot;
         &lt;&lt; endl &lt;&lt; endl &lt;&lt; &quot;  Ihr System kostet &quot; &lt;&lt; aMin &lt;&lt; &quot; bis &quot; &lt;&lt; aMax &lt;&lt; &quot; Euro.&quot;
         &lt;&lt; endl         &lt;&lt; &quot;  Sie muessen noch &quot; &lt;&lt; aMonate &lt;&lt; &quot; bis &quot; &lt;&lt; bMonate &lt;&lt; &quot; Monate sparen.&quot;;           

    cout &lt;&lt; endl &lt;&lt; endl &lt;&lt; &quot;  ------------------------------------------------------------- &quot;
         &lt;&lt; endl &lt;&lt; endl &lt;&lt; &quot;  &quot;;
    system(&quot;PAUSE&quot;);
    return EXIT_SUCCESS;
}
</code></pre>
<p>Nun möchte ich noch das das ganze in eine .txt-Datei gespeichert wird. Möglichst in den selben Ordner in der sich die .exe befindet.</p>
<p>Mein C/C++-Wissen übersteigt kaum dem, was man in einem halben Jahr so in der Schule lernt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1216122</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1216122</guid><dc:creator><![CDATA[MEETyA]]></dc:creator><pubDate>Wed, 24 Jan 2007 15:46:07 GMT</pubDate></item><item><title><![CDATA[Reply to .txt Datei mit inhalt erstellen on Wed, 24 Jan 2007 16:00:41 GMT]]></title><description><![CDATA[<p>MEETyA schrieb:</p>
<blockquote>
<p>Mein C/C++-Wissen übersteigt kaum dem, was man in einem halben Jahr so in der Schule lernt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
</blockquote>
<p>Dann fangen wir mit den Basics an: Es keine Sprache C/C++. Die Sprachen sind strikt zu trennen. Beide Sprachen haben, obwohl C einst die Basis von C++ bildete, nicht wirklich viel miteinander zu tun. Zu unterschiedlich die Konzepte sind.</p>
<p>Dein Code ist (zumindest von den genutzten Sprachmitteln) C++. Du bist hier leider falsch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1216139</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1216139</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 24 Jan 2007 16:00:41 GMT</pubDate></item><item><title><![CDATA[Reply to .txt Datei mit inhalt erstellen on Wed, 24 Jan 2007 16:00:58 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile.php?mode=viewprofile&amp;u=14811" rel="nofollow">TactX</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=10" rel="nofollow">ANSI C</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=15" rel="nofollow">C++</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1216140</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1216140</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Wed, 24 Jan 2007 16:00:58 GMT</pubDate></item><item><title><![CDATA[Reply to .txt Datei mit inhalt erstellen on Wed, 24 Jan 2007 16:17:45 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Di solltest mal nach ifstream und ofstream google. Damit bekommst du Lese- und Schreibzugriff auf eine Datei deiner Wahl, die du dann manipulieren kannst.</p>
<p>chrische</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1216154</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1216154</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 24 Jan 2007 16:17:45 GMT</pubDate></item><item><title><![CDATA[Reply to .txt Datei mit inhalt erstellen on Wed, 24 Jan 2007 20:00:23 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include&lt;fstream&gt;

//.......

ofstream ausgabe(&quot;keinAhnung.txt&quot;);

    if(!ausgabe){
                  cerr &lt;&lt; &quot;keineAhnung.txt&quot;
                       &lt;&lt; &quot; kann nicht geöffnet werden!\n&quot;;
                  exit(-1);
                  }
    //Fehlerüberprüfung

    ausgabe &lt;&lt; //dein ganzes Zeug (kannst du mit nem String machen);

    ausgabe.close();
    //schließen
</code></pre>
<p>habs ned getestet, (bin auch noch Totalanfänger!:D) aber ich denke es müsste so gehen! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1216360</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1216360</guid><dc:creator><![CDATA[*lt**Exit*gt*]]></dc:creator><pubDate>Wed, 24 Jan 2007 20:00:23 GMT</pubDate></item><item><title><![CDATA[Reply to .txt Datei mit inhalt erstellen on Wed, 24 Jan 2007 20:13:59 GMT]]></title><description><![CDATA[<p><a href="http://www.cplusplus.com/doc/tutorial/files.html" rel="nofollow">http://www.cplusplus.com/doc/tutorial/files.html</a><br />
<a href="http://www.fesg.tu-muenchen.de/dieter/oop/cppio.html" rel="nofollow">http://www.fesg.tu-muenchen.de/dieter/oop/cppio.html</a></p>
<p>sofern du den Englischen mächtig bist müsten die 2 Links alles wissenswerte beinhalten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1216381</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1216381</guid><dc:creator><![CDATA[Raven2]]></dc:creator><pubDate>Wed, 24 Jan 2007 20:13:59 GMT</pubDate></item></channel></rss>