<?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[savetofile]]></title><description><![CDATA[<p>Hallo liebe Community,</p>
<p>wir haben in der Berufsschule eine Projekt-arbeit aufbekommen, in der wir eine Bootsverwaltungs programm in c++ schreiben solln.</p>
<p>Hier mal mein Code, bis ich gekommen bin.<br />
Ich will in der Funktion Neubuchung(); den Namen des Kunden und die Bootsnummer oder Farben einlesen. Diese daten solln dann in eine extra Funktion Namens safetofile() im .txt Format gespeichert werden. Die Funktion Statisktik soll dann Zeilenweise in .txt wieder einlesen und dann in einem Array ausgeben.</p>
<p>Ist das möglich, wenn ja wie mach ich das? Also hab mich auch schon teilweise eingelesen in fsteam, aber irgendwie fehlt mir da der Schlüssel zur tür.</p>
<p>Wäre super wenn ihr mir tipps geben könntet,</p>
<p>danke im voraus.</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include &quot;func.h&quot;
#include &lt;fstream&gt;

using namespace std;

                //Globale Variablen
char(pause);

void exit()
{
	cout &lt;&lt; &quot;\nPress any key to continue &quot; &lt;&lt;endl;
	cin.ignore();
	cin.get(pause);
	system(&quot;cls&quot;);

    }

void menue() //Main Menü Function
{
  system(&quot;cls&quot;);
  int choice;
	// Begin des Hauptmenü
	do
      {
    //	Header(); //Aufruf der Header Funktion ja, aber lieber so
    header();

     cout &lt;&lt; &quot; \n\n\nSie befinden sich im Hauptmenue der Bootsverwaltung\n&quot;;
     cout &lt;&lt; &quot; ===============================================\n&quot;;
     cout &lt;&lt; &quot; 1. Buchungsmenue\n&quot;;	
     cout &lt;&lt; &quot; 2. Bootemenue\n&quot;;
     cout &lt;&lt; &quot; 3. Statistikmenue\n&quot;;
     cout &lt;&lt; &quot; 4. Exit\n&quot;;

     cout &lt;&lt; &quot;\nIhre Wahl: &quot;;

    do
      {
          choice=cin.get();
      } 

    while (choice &lt; '1' || choice &gt; '4');

    switch (choice)
    {
     case '1' :buchung();   break;
     case '2' :boote();     break;
     case '3' :statistik(); break;
     case '4' :exit();      break;
     default  :cout &lt;&lt;&quot;falsche Eingabe&quot;;break;
    }
    }
     while (choice !=4); 

}

void header() //Header Menü

     {

//wenn das hier unten ausgegeben werden soll, dann muss aber überall ein cout davor     
     cout&lt;&lt;&quot;\t\t\t========================&quot;;   
     cout&lt;&lt;&quot;\n\t\t\t*** Bootsverwaltung ***\n&quot;;
     cout&lt;&lt;&quot;\t\t\t========================&quot;;
      }

//Die Funktionen müssen auch definiert werden, wenn sie schon aufgerufen werden.

void buchung()
{

     system(&quot;cls&quot;);
     int choice;

                //Buchungsmenue
     do
     {
    header();
    cout&lt;&lt;&quot;\n\nBuchungsmenue\n&quot;;
    cout&lt;&lt;&quot;=============\n\n&quot;;
    cout&lt;&lt;&quot;1. Neue Buchung\n&quot;;
    cout&lt;&lt;&quot;2. Zurueck ins Hauptmenue\n&quot;;

    cout &lt;&lt; &quot;\n\nIhre Wahl: &quot;;
         do
         {
           choice=cin.get();
           }

           while (choice &lt; '1' || choice &gt; '2');

    switch (choice)

    {
     case '1' :neubuchung();break;
     case '2' :menue();break;
     default  :break;
     }
     }
     while (choice != '1');

     exit();

     cout&lt;&lt;&quot;Buchung&quot;;
     }

void statistik()
{

     int boot[10];
     int i;

     system(&quot;cls&quot;);
     header();

     cout&lt;&lt;&quot;\n\n\tStatistik\n&quot;;
     cout &lt;&lt; &quot;\tStandort Berlin : \n&quot;;

      for(i=0;i&lt;10;i=i+1)
        {
        boot[i]=i;
        cout &lt;&lt; boot[i] &lt;&lt;&quot;\n&quot;;
         }

      /*for(i=0;i&lt;10;i=i+1)
        {
        cout&lt;&lt;boot[i]&lt;&lt;&quot;\n&quot;;
         }*/

      cin.get();

     }

void boote()
{    
     system(&quot;cls&quot;);
     header();
     cout&lt;&lt;&quot;Boote&quot;;

     }

void neubuchung()
{    
     char boot[20];

     system(&quot;cls&quot;);
     header();
     cout&lt;&lt;&quot;\nBuchungsmenue\n&quot;;
     cout&lt;&lt;&quot;===============\n&quot;;
     cout&lt;&lt;&quot;Bitte Name eingeben: &quot;;
     boot[20]=cin.get();

     }

/*void savetofile()
{
	 fstream fout(&quot;boote.dta&quot; , ios::app);
	 fout.write();
	 fout.close();
     fstream fout2(&quot;data.dta&quot; , ios::app);
	 fout2.write();
	 fout2.close();
		}*/
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/212338/savetofile</link><generator>RSS for Node</generator><lastBuildDate>Wed, 14 Oct 2026 20:21:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/212338.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 05 May 2008 07:34:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to savetofile on Mon, 05 May 2008 07:37:48 GMT]]></title><description><![CDATA[<p>Hallo liebe Community,</p>
<p>wir haben in der Berufsschule eine Projekt-arbeit aufbekommen, in der wir eine Bootsverwaltungs programm in c++ schreiben solln.</p>
<p>Hier mal mein Code, bis ich gekommen bin.<br />
Ich will in der Funktion Neubuchung(); den Namen des Kunden und die Bootsnummer oder Farben einlesen. Diese daten solln dann in eine extra Funktion Namens safetofile() im .txt Format gespeichert werden. Die Funktion Statisktik soll dann Zeilenweise in .txt wieder einlesen und dann in einem Array ausgeben.</p>
<p>Ist das möglich, wenn ja wie mach ich das? Also hab mich auch schon teilweise eingelesen in fsteam, aber irgendwie fehlt mir da der Schlüssel zur tür.</p>
<p>Wäre super wenn ihr mir tipps geben könntet,</p>
<p>danke im voraus.</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include &quot;func.h&quot;
#include &lt;fstream&gt;

using namespace std;

                //Globale Variablen
char(pause);

void exit()
{
	cout &lt;&lt; &quot;\nPress any key to continue &quot; &lt;&lt;endl;
	cin.ignore();
	cin.get(pause);
	system(&quot;cls&quot;);

    }

void menue() //Main Menü Function
{
  system(&quot;cls&quot;);
  int choice;
	// Begin des Hauptmenü
	do
      {
    //	Header(); //Aufruf der Header Funktion ja, aber lieber so
    header();

     cout &lt;&lt; &quot; \n\n\nSie befinden sich im Hauptmenue der Bootsverwaltung\n&quot;;
     cout &lt;&lt; &quot; ===============================================\n&quot;;
     cout &lt;&lt; &quot; 1. Buchungsmenue\n&quot;;	
     cout &lt;&lt; &quot; 2. Bootemenue\n&quot;;
     cout &lt;&lt; &quot; 3. Statistikmenue\n&quot;;
     cout &lt;&lt; &quot; 4. Exit\n&quot;;

     cout &lt;&lt; &quot;\nIhre Wahl: &quot;;

    do
      {
          choice=cin.get();
      } 

    while (choice &lt; '1' || choice &gt; '4');

    switch (choice)
    {
     case '1' :buchung();   break;
     case '2' :boote();     break;
     case '3' :statistik(); break;
     case '4' :exit();      break;
     default  :cout &lt;&lt;&quot;falsche Eingabe&quot;;break;
    }
    }
     while (choice !=4); 

}

void header() //Header Menü

     {

//wenn das hier unten ausgegeben werden soll, dann muss aber überall ein cout davor     
     cout&lt;&lt;&quot;\t\t\t========================&quot;;   
     cout&lt;&lt;&quot;\n\t\t\t*** Bootsverwaltung ***\n&quot;;
     cout&lt;&lt;&quot;\t\t\t========================&quot;;
      }

//Die Funktionen müssen auch definiert werden, wenn sie schon aufgerufen werden.

void buchung()
{

     system(&quot;cls&quot;);
     int choice;

                //Buchungsmenue
     do
     {
    header();
    cout&lt;&lt;&quot;\n\nBuchungsmenue\n&quot;;
    cout&lt;&lt;&quot;=============\n\n&quot;;
    cout&lt;&lt;&quot;1. Neue Buchung\n&quot;;
    cout&lt;&lt;&quot;2. Zurueck ins Hauptmenue\n&quot;;

    cout &lt;&lt; &quot;\n\nIhre Wahl: &quot;;
         do
         {
           choice=cin.get();
           }

           while (choice &lt; '1' || choice &gt; '2');

    switch (choice)

    {
     case '1' :neubuchung();break;
     case '2' :menue();break;
     default  :break;
     }
     }
     while (choice != '1');

     exit();

     cout&lt;&lt;&quot;Buchung&quot;;
     }

void statistik()
{

     int boot[10];
     int i;

     system(&quot;cls&quot;);
     header();

     cout&lt;&lt;&quot;\n\n\tStatistik\n&quot;;
     cout &lt;&lt; &quot;\tStandort Berlin : \n&quot;;

      for(i=0;i&lt;10;i=i+1)
        {
        boot[i]=i;
        cout &lt;&lt; boot[i] &lt;&lt;&quot;\n&quot;;
         }

      /*for(i=0;i&lt;10;i=i+1)
        {
        cout&lt;&lt;boot[i]&lt;&lt;&quot;\n&quot;;
         }*/

      cin.get();

     }

void boote()
{    
     system(&quot;cls&quot;);
     header();
     cout&lt;&lt;&quot;Boote&quot;;

     }

void neubuchung()
{    
     char boot[20];

     system(&quot;cls&quot;);
     header();
     cout&lt;&lt;&quot;\nBuchungsmenue\n&quot;;
     cout&lt;&lt;&quot;===============\n&quot;;
     cout&lt;&lt;&quot;Bitte Name eingeben: &quot;;
     boot[20]=cin.get();

     }

/*void savetofile()
{
	 fstream fout(&quot;boote.dta&quot; , ios::app);
	 fout.write();
	 fout.close();
     fstream fout2(&quot;data.dta&quot; , ios::app);
	 fout2.write();
	 fout2.close();
		}*/
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1503438</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503438</guid><dc:creator><![CDATA[Shrek2k1]]></dc:creator><pubDate>Mon, 05 May 2008 07:37:48 GMT</pubDate></item><item><title><![CDATA[Reply to savetofile on Mon, 05 May 2008 08:16:29 GMT]]></title><description><![CDATA[<p>such mal nach fstream,istream,ostream. Da wirst du alles finden was du brauchst.<br />
am besten du guckst hier:<br />
<a href="http://www.cplusplus.com/reference/" rel="nofollow">http://www.cplusplus.com/reference/</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1503458</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503458</guid><dc:creator><![CDATA[Firefighter]]></dc:creator><pubDate>Mon, 05 May 2008 08:16:29 GMT</pubDate></item><item><title><![CDATA[Reply to savetofile on Mon, 05 May 2008 12:44:42 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">void neubuchung()
{    

            cout &lt;&lt; &quot;Name : &quot;;   // Der Name soll in die test1.txt gespeichert werden
            cin &gt;&gt; name;

/*  
    fstream f;             
    f.open(&quot;test.txt&quot;, ios::out);
    f &lt;&lt; &quot;Dieser Text geht in die Datei&quot; &lt;&lt; endl;
    f.close();*/
</code></pre>
<p>Ich kann zwar wie oben in eine datei über f&lt;&lt; reinsschreiben. Wie schaff ich es denn von einer Variablen, den Wert z.b. der Name einer Variablen in eine Textdatei zu speichern und diese auf einen Array wieder auszulesen.<br />
Stichwort Pointer....wäre nett wenn mir einer ein kleines Beispiel dazu schreiben könnte!</p>
<p>mfg Shrek</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1503622</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503622</guid><dc:creator><![CDATA[Shrek2k1]]></dc:creator><pubDate>Mon, 05 May 2008 12:44:42 GMT</pubDate></item><item><title><![CDATA[Reply to savetofile on Mon, 05 May 2008 13:36:35 GMT]]></title><description><![CDATA[<p>Indem DU definierst, was wo gespeichert wird. Und entsprechend liest du es dann wieder aus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1503658</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503658</guid><dc:creator><![CDATA[ceplusplus@loggedoff]]></dc:creator><pubDate>Mon, 05 May 2008 13:36:35 GMT</pubDate></item><item><title><![CDATA[Reply to savetofile on Mon, 05 May 2008 14:03:29 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">//lesen
    std::string lesen_aus_datei;
    ifstream f(&quot;test.txt&quot;);
    int i =0;
    while(f&gt;&gt;lesen_aus_datei)
    {
      i+=i;
    }
cout&lt;&lt;&quot;Es befinden sich &quot;&lt;&lt;i&lt;&lt;&quot; Woerter in der Datei&quot;&lt;&lt;endl;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1503666</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503666</guid><dc:creator><![CDATA[Firefighter]]></dc:creator><pubDate>Mon, 05 May 2008 14:03:29 GMT</pubDate></item><item><title><![CDATA[Reply to savetofile on Mon, 05 May 2008 13:59:32 GMT]]></title><description><![CDATA[<p>Naja paar Fehler, <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/15364">@Firefighter</a>. so ist es richtig:</p>
<pre><code class="language-cpp">#include &lt;fstream&gt;
#include &lt;string&gt;
using namespace std;

...

ifstream readFile(&quot;Text.txt&quot;);

string read;
int numWords = 0;
while(readFile &gt;&gt; read) 
	++numWords;

cout &lt;&lt; &quot;Es befinden sich &quot; &lt;&lt; numWords &lt;&lt; &quot; Woerter in der Datei&quot; &lt;&lt; endl;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1503684</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503684</guid><dc:creator><![CDATA[ceplusplus@loggedoff]]></dc:creator><pubDate>Mon, 05 May 2008 13:59:32 GMT</pubDate></item><item><title><![CDATA[Reply to savetofile on Mon, 05 May 2008 14:03:09 GMT]]></title><description><![CDATA[<p>ok gut ich habe die datei vergessen das ist natürlich schwerwiegend sonst ließt er ins datennirvana <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /> Danke für die Verbesserung.(Das kommt davon wenn mal immer als erster gleich antworten will <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /> ):D</p>
<p>EDIT:Werde es umeditieren</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1503686</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503686</guid><dc:creator><![CDATA[Firefighter]]></dc:creator><pubDate>Mon, 05 May 2008 14:03:09 GMT</pubDate></item><item><title><![CDATA[Reply to savetofile on Mon, 05 May 2008 15:12:42 GMT]]></title><description><![CDATA[<p>hi,</p>
<p>danke erstmal für die Hilfe...ich sass heute den ganzen scheiss Vormittag dran und hab mir den kopf darüber zerbrochen. Leider bin ich auch der einzige, der bei der Project arbeit wirklich zeit investiert, obwohl ich nicht gerade der beste in C++ bin.</p>
<p>Zu dem Quellcode,<br />
wäre es jetzt noch möglich, dass ich das File auswerte, quasi was in dem File drin steht, weil jetzt zeigt er mir ja nur an, wieviel drin steht.</p>
<p>Danke im vorraus,</p>
<p>MfG Shrek</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1503747</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503747</guid><dc:creator><![CDATA[Shrek2k1]]></dc:creator><pubDate>Mon, 05 May 2008 15:12:42 GMT</pubDate></item><item><title><![CDATA[Reply to savetofile on Mon, 05 May 2008 15:22:02 GMT]]></title><description><![CDATA[<p>naklar du liest es doch in einen String ein, und den kannst du dann auswerten/bearbeiten</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1503754</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503754</guid><dc:creator><![CDATA[Firefighter]]></dc:creator><pubDate>Mon, 05 May 2008 15:22:02 GMT</pubDate></item></channel></rss>