<?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[Textprogramm!!!+speichern und öffnen]]></title><description><![CDATA[<p>Schreibe gerade ein Betriebssystem und dazu ein Textprogramm.<br />
wie kann man (wenn ein Programm schon einmal geschlossen wurde) Textdateien laden</p>
<pre><code class="language-cpp">case 'a':for(int i = 0;i&lt;zaehler;i++)
                                 {
                                     if(text[i] == '#')
                                     {
                                         cout &lt;&lt; endl;
                                     }    
                                     cout &lt;&lt; text[i];   
                                 }
                                 cout &lt;&lt; &quot;\n\nWollen Sie speichern(y\\n)\n&quot;;
                                 cin &gt;&gt; Auswahl;
                                 if(Auswahl == 'y')
                                 {
                                    FILE *stream;
                                    char msg[20];
                                    /* Öffnet eine Datei zur Aktualisierung */
                                    stream = fopen(&quot;Textprogramm.txt&quot;, &quot;w+&quot;);
                                    /* Schreibt einen String in die Datei */
                                    fwrite(text, strlen(text), 1, stream);
                                    /* Setzt den Dateizeiger an den Dateianfang
                                    fseek(stream, 0, SEEK_SET);
                                    /* Liest einen String aus der Datei */
                                    fgets(msg, strlen(text)+1, stream);
                                    /* Zeigt den String an */
                                    printf(&quot;%s&quot;, msg);
                                    fclose(stream);break;
                                 }
                                 break;
                        case 'm':break;
                    }         
                    break;
 //------------------------------------------------------------------------
          case 'o': FILE *stream;
                    char msg[20];
                    //öffnet Datei
                    freopen (&quot;Textprogramm.txt&quot;,&quot;r&quot;,stream);
                    /* Setzt den Dateizeiger an den Dateianfang */
                    fseek(stream, 0, SEEK_SET);
                    /* Liest einen String aus der Datei */
                    fgets(msg, strlen(text)+1, stream);
                    /* Zeigt den String an */
                    cout &lt;&lt; &quot;Der Text:\n\n&quot;;
                    printf(&quot;%s&quot;,text,msg);
                    fclose(stream);
                    getchar();
                    getchar();
                    break;
</code></pre>
<p>φζηΓΔθψωλνΣ</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/152657/textprogramm-speichern-und-öffnen</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 02:47:44 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/152657.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 08 Jul 2006 11:38:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Textprogramm!!!+speichern und öffnen on Sat, 08 Jul 2006 11:38:17 GMT]]></title><description><![CDATA[<p>Schreibe gerade ein Betriebssystem und dazu ein Textprogramm.<br />
wie kann man (wenn ein Programm schon einmal geschlossen wurde) Textdateien laden</p>
<pre><code class="language-cpp">case 'a':for(int i = 0;i&lt;zaehler;i++)
                                 {
                                     if(text[i] == '#')
                                     {
                                         cout &lt;&lt; endl;
                                     }    
                                     cout &lt;&lt; text[i];   
                                 }
                                 cout &lt;&lt; &quot;\n\nWollen Sie speichern(y\\n)\n&quot;;
                                 cin &gt;&gt; Auswahl;
                                 if(Auswahl == 'y')
                                 {
                                    FILE *stream;
                                    char msg[20];
                                    /* Öffnet eine Datei zur Aktualisierung */
                                    stream = fopen(&quot;Textprogramm.txt&quot;, &quot;w+&quot;);
                                    /* Schreibt einen String in die Datei */
                                    fwrite(text, strlen(text), 1, stream);
                                    /* Setzt den Dateizeiger an den Dateianfang
                                    fseek(stream, 0, SEEK_SET);
                                    /* Liest einen String aus der Datei */
                                    fgets(msg, strlen(text)+1, stream);
                                    /* Zeigt den String an */
                                    printf(&quot;%s&quot;, msg);
                                    fclose(stream);break;
                                 }
                                 break;
                        case 'm':break;
                    }         
                    break;
 //------------------------------------------------------------------------
          case 'o': FILE *stream;
                    char msg[20];
                    //öffnet Datei
                    freopen (&quot;Textprogramm.txt&quot;,&quot;r&quot;,stream);
                    /* Setzt den Dateizeiger an den Dateianfang */
                    fseek(stream, 0, SEEK_SET);
                    /* Liest einen String aus der Datei */
                    fgets(msg, strlen(text)+1, stream);
                    /* Zeigt den String an */
                    cout &lt;&lt; &quot;Der Text:\n\n&quot;;
                    printf(&quot;%s&quot;,text,msg);
                    fclose(stream);
                    getchar();
                    getchar();
                    break;
</code></pre>
<p>φζηΓΔθψωλνΣ</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1093840</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1093840</guid><dc:creator><![CDATA[java.exe]]></dc:creator><pubDate>Sat, 08 Jul 2006 11:38:17 GMT</pubDate></item><item><title><![CDATA[Reply to Textprogramm!!!+speichern und öffnen on Sat, 08 Jul 2006 11:48:42 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich verstehe nicht ganz dein Problem:</p>
<p>wie kann man (wenn ein Programm schon einmal geschlossen wurde) Textdateien laden</p>
<p>....</p>
<p>Wenn ein Programm schon einmal geschlossen wurde!?</p>
<p>MFG winexec*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1093847</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1093847</guid><dc:creator><![CDATA[winexec*]]></dc:creator><pubDate>Sat, 08 Jul 2006 11:48:42 GMT</pubDate></item><item><title><![CDATA[Reply to Textprogramm!!!+speichern und öffnen on Sat, 08 Jul 2006 11:56:03 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Bist du denn mit dem BS schon fertig?</p>
<p>chrische</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1093850</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1093850</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sat, 08 Jul 2006 11:56:03 GMT</pubDate></item><item><title><![CDATA[Reply to Textprogramm!!!+speichern und öffnen on Sat, 08 Jul 2006 12:05:11 GMT]]></title><description><![CDATA[<p>1. ja mit dem OS, bin ich fertig!!</p>
<p>2. Wenn ich den Text speichere und dann sofort lade, dann funktioniert es.<br />
Aber wenn ich das Programm schließe und dann wieder starte ist die Textdatei leer. Als ob beim Laden die .txt Datei überschrieben wird.</p>
<p>Hier der ganze Code</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;stdlib.h&gt;

using namespace std;

//------------------------------------------------------------------------------------
int Hilfe()
{
    char Auswahl;
    cout &lt;&lt; &quot;\a\a     -------------------------------------------------\n&quot;;
    cout &lt;&lt; &quot;      Willkommen bei der MF Softwareproduktions Hilfe\n&quot;;
    cout &lt;&lt; &quot;     -------------------------------------------------\n\n&quot;;
    cout &lt;&lt; &quot;s........Das Speichern\n&quot;;
    cout &lt;&lt; &quot;b........Befehle\n&quot;;
    cout &lt;&lt; &quot;p........Die Programmiersprache IPL\n&quot;;
    cin &gt;&gt; Auswahl;
    switch(Auswahl)
    {
        case 's': cout &lt;&lt; &quot;\n\nDas Speichern:\n&quot;;
                  cout &lt;&lt; &quot;Keine Zwielaute!\n&quot;;
                  cout &lt;&lt; &quot;Jeder Text wird auf Name.txt gespeichert(in dem Ordner in dem Sie\ndas MF Softwareproduction Texttool installiert haben&quot;;
                  cout &lt;&lt; &quot;Zum Oeffnen dieses Textes verwenden Sie im\nHauptmenue den Auswahlpunkt &quot;&quot;oeffnen&quot;&quot;\n&quot;;
                  getchar();
                  break;
        case 'b': cout &lt;&lt; &quot;Die Befehle:\n&quot;;
                  cout &lt;&lt; &quot;Leerzeichen(Funktionszeichen): Geben Sie &quot;&quot;-&quot;&quot; fuer ein Leerzeichen ein\n&quot;;
                  cout &lt;&lt; &quot;Absatz(Funktionszeichen): Geben Sie &quot;&quot;#&quot;&quot; fuer einen Absatz ein\n&quot;;
                  cout &lt;&lt; &quot;Fertig(Funktionszeichen): Geben Sie &quot;&quot;+&quot;&quot; wenn der Text fertig ist ein\n&quot;;
                  cout &lt;&lt; &quot;Alle anderen Zeichen sind primaer zum erstellen des Textes gedacht\n&quot;;
                  cout &lt;&lt; &quot;\aHINWEISS: Funktionszeichen duerfen nicht im Text inkludiert werden\n\n\n&quot;;
                  getchar();
                  break;
    }      
    getchar();
}
//--------------------------------------------------------------------------------------------    
int main(int argc, char *argv[])
{
  char Auswahl, zaehler;
  zaehler = -1;
  char text[100000];
//---------------------------------------------------------------------------------------------
  while(Auswahl != 'q')
  {
      cout &lt;&lt; &quot;\n\n       -------------------------------------\n&quot;;
      cout &lt;&lt; &quot;       || MF Softwareproductions Texttool ||\n&quot;;
      cout &lt;&lt; &quot;       -------------------------------------\n\n\n\n&quot;;  
      cout &lt;&lt; &quot;n........Neuer Text&quot;&lt;&lt;endl;
      cout &lt;&lt; &quot;h........Hilfe&quot;&lt;&lt;endl;
      cout &lt;&lt; &quot;o........oeffnen\n&quot;;
      cout &lt;&lt; &quot;q........Quit\n&quot;&lt;&lt;endl;
      cin &gt;&gt; Auswahl;
      switch(Auswahl)
      {
//---------------------------------------------------------------------
          case 'n': cout &lt;&lt; &quot;Text:\n\n&quot;; 
                   do
                   {
                      zaehler++;
                      cin &gt;&gt; text[zaehler];
                      if(text[zaehler] == '-')
                      {
                         text[zaehler] = ' ';
                      } 
                   }while(text[zaehler] != '+');
                    cout &lt;&lt; &quot;\n\na......Text anzeigen\n&quot;;
                    cout &lt;&lt; &quot;m......Hauptmenue\n&quot;;
                    cin &gt;&gt; Auswahl;
                    switch(Auswahl)
                    {
                        case 'a':for(int i = 0;i&lt;zaehler;i++)
                                 {
                                     if(text[i] == '#')
                                     {
                                         cout &lt;&lt; endl;
                                     }    
                                     cout &lt;&lt; text[i];   
                                 }
                                 cout &lt;&lt; &quot;\n\nWollen Sie speichern(y\\n)\n&quot;;
                                 cin &gt;&gt; Auswahl;
                                 if(Auswahl == 'y')
                                 {
                                    FILE *stream;
                                    char msg[20];
                                    /* Öffnet eine Datei zur Aktualisierung */
                                    stream = fopen(&quot;Textprogramm.txt&quot;, &quot;w+&quot;);
                                    /* Schreibt einen String in die Datei */
                                    fwrite(text, strlen(text), 1, stream);
                                    /* Setzt den Dateizeiger an den Dateianfang */
                                    fseek(stream, 0, SEEK_SET);
                                    /* Liest einen String aus der Datei */
                                    fgets(msg, strlen(text)+1, stream);
                                    /* Zeigt den String an */
                                    printf(&quot;%s&quot;, msg);
                                    fclose(stream);break;
                                 }
                                 break;
                        case 'm':break;
                    }         
                    break;
 //------------------------------------------------------------------------
          case 'o': FILE *stream;
                    char msg[20];
                    //öffnet Datei
                    freopen (&quot;Textprogramm.txt&quot;,&quot;r&quot;,stream);
                    /* Setzt den Dateizeiger an den Dateianfang */
                    fseek(stream, 0, SEEK_SET);
                    /* Liest einen String aus der Datei */
                    fgets(msg, strlen(text)+1, stream);
                    /* Zeigt den String an */
                    cout &lt;&lt; &quot;Der Text:\n\n&quot;;
                    printf(&quot;%s&quot;,text,msg);
                    fclose(stream);
                    getchar();
                    getchar();
                    break;

 //------------------------------------------------------------------------                   
          case 'h':Hilfe();break;
 //------------------------------------------------------------------------     
      } 
  }        	
      return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1093857</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1093857</guid><dc:creator><![CDATA[java.exe]]></dc:creator><pubDate>Sat, 08 Jul 2006 12:05:11 GMT</pubDate></item><item><title><![CDATA[Reply to Textprogramm!!!+speichern und öffnen on Sat, 08 Jul 2006 12:49:58 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich kenn mich leider nicht sehr mit C aus, aber ich glaube du vergisst etwas mit dem Buffer.</p>
<p>In C++ funktioniert das:</p>
<pre><code class="language-cpp">stream.open (&quot;Textprogramm.txt&quot;);
stream.getline(text,50); //natürlich nicht das gleiche wie zeichen einzulesen
text[50] = '\0';                   
cout &lt;&lt; &quot;Der Text:\n\n&quot;;
cout &lt;&lt; text;
stream.close();
</code></pre>
<p>Nebenbei: Wenn du das Programm neustartest und du strlen(text) ausführst bekommst du 0 zurück. Das ist dir klar?</p>
<p>Edit*: Ich habe es einmal mit C ausprobiert:</p>
<pre><code class="language-cpp">case 'o': FILE *streamA;
                    char msg[20];
                    //öffnet Datei
                    streamA = fopen (&quot;Textprogramm.txt&quot;,&quot;r&quot;);
                    fseek(streamA, 0, SEEK_SET);
                    fgets(msg, 10, streamA);
                    msg[14] = '\0';
                    cout &lt;&lt; &quot;Der Text:\n\n&quot;;
                    printf(&quot;%s&quot;,msg);
                    fclose(streamA);
                    getchar();
                    getchar();
                    break;
</code></pre>
<p>funktioniert doch einbahnfrei oder?</p>
<p>MFG winexec*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1093870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1093870</guid><dc:creator><![CDATA[winexec*]]></dc:creator><pubDate>Sat, 08 Jul 2006 12:49:58 GMT</pubDate></item><item><title><![CDATA[Reply to Textprogramm!!!+speichern und öffnen on Sat, 08 Jul 2006 12:52:14 GMT]]></title><description><![CDATA[<p>Braucht man da eine bestimmte Headerdatei, <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> oder fehlt noch was?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1093876</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1093876</guid><dc:creator><![CDATA[java.exe]]></dc:creator><pubDate>Sat, 08 Jul 2006 12:52:14 GMT</pubDate></item><item><title><![CDATA[Reply to Textprogramm!!!+speichern und öffnen on Sat, 08 Jul 2006 12:55:21 GMT]]></title><description><![CDATA[<p>Danke, hat sich erledigt!<br />
Kennst du Assembler?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1093879</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1093879</guid><dc:creator><![CDATA[java.exe]]></dc:creator><pubDate>Sat, 08 Jul 2006 12:55:21 GMT</pubDate></item><item><title><![CDATA[Reply to Textprogramm!!!+speichern und öffnen on Sat, 08 Jul 2006 13:05:35 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Kennen.. sicher</p>
<p>MFG winexec*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1093886</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1093886</guid><dc:creator><![CDATA[winexec*]]></dc:creator><pubDate>Sat, 08 Jul 2006 13:05:35 GMT</pubDate></item><item><title><![CDATA[Reply to Textprogramm!!!+speichern und öffnen on Sat, 08 Jul 2006 19:25:20 GMT]]></title><description><![CDATA[<p>Beim öffnen gibt das Programm immer nur eine Zeile aus.<br />
Kann man da irgendwie in die nächste Zeile springen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1094130</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1094130</guid><dc:creator><![CDATA[java.exe]]></dc:creator><pubDate>Sat, 08 Jul 2006 19:25:20 GMT</pubDate></item></channel></rss>