<?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[frage: wie kann ich einen Text direkt in eine .txt Datei speicerhn OHNE ihn vorher z.B in eine ListBox zu schreiben aus]]></title><description><![CDATA[<p>hallo die frage steht ja schon oben..</p>
<pre><code class="language-cpp">void suche(AnsiString pfad)
{
Form2-&gt;Caption=pfad;

TSearchRec sr;
pfad += &quot;\\&quot;;
if (FindFirst(pfad + &quot;*&quot;, faAnyFile, sr) == 0)
  {
    do
    {
                if ((sr.Name != &quot;.&quot;)&amp;&amp;(sr.Name != &quot;..&quot;))
                {

                      if (sr.Attr == faDirectory)
                      {
                                suche(pfad+sr.Name);
                      }
                      else
                      {
                              Form2-&gt;ListBox1-&gt;Items-&gt;Add(pfad+sr.Name);
                              Form2-&gt;ListBox1-&gt;Items-&gt;SaveToFile(&quot;dateien.txt&quot;);
                              Form2-&gt;StringGrid1-&gt;RowCount = Form2-&gt;StringGrid1-&gt;RowCount + 1;
                              Form2-&gt;StringGrid1-&gt;Cells[0][Form2-&gt;StringGrid1-&gt;RowCount-1] = sr.Name;
                              Form2-&gt;StringGrid1-&gt;Cells[1][Form2-&gt;StringGrid1-&gt;RowCount-1] = IntToStr(sr.Size);

                      }
                }

    } while (FindNext(sr) == 0);
    FindClose(sr);
  }
}

void __fastcall TForm2::Button1Click(TObject *Sender)
{
StringGrid1-&gt;RowCount = 1;
StringGrid1-&gt;RowCount = 0;
suche(Edit1-&gt;Text);
}
</code></pre>
<p>ein ausschnitt aus meinem c++ quelltext..ihr seht ich schreibe das ausgelesene erst in eine ListBox und dann wird es aus der ListBox in eine .txt Datei gespeichert..<br />
Das möchte ich aber umgehen..ich möchte das das Programm alle gefundenen Daten SOFORT in eine .txt Datei schreibt..</p>
<p>könntet ihr mir helfen??<br />
DANKE</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/113446/frage-wie-kann-ich-einen-text-direkt-in-eine-txt-datei-speicerhn-ohne-ihn-vorher-z-b-in-eine-listbox-zu-schreiben-aus</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Jul 2026 04:39:46 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/113446.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 23 Jun 2005 05:13:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to frage: wie kann ich einen Text direkt in eine .txt Datei speicerhn OHNE ihn vorher z.B in eine ListBox zu schreiben aus on Thu, 23 Jun 2005 05:13:25 GMT]]></title><description><![CDATA[<p>hallo die frage steht ja schon oben..</p>
<pre><code class="language-cpp">void suche(AnsiString pfad)
{
Form2-&gt;Caption=pfad;

TSearchRec sr;
pfad += &quot;\\&quot;;
if (FindFirst(pfad + &quot;*&quot;, faAnyFile, sr) == 0)
  {
    do
    {
                if ((sr.Name != &quot;.&quot;)&amp;&amp;(sr.Name != &quot;..&quot;))
                {

                      if (sr.Attr == faDirectory)
                      {
                                suche(pfad+sr.Name);
                      }
                      else
                      {
                              Form2-&gt;ListBox1-&gt;Items-&gt;Add(pfad+sr.Name);
                              Form2-&gt;ListBox1-&gt;Items-&gt;SaveToFile(&quot;dateien.txt&quot;);
                              Form2-&gt;StringGrid1-&gt;RowCount = Form2-&gt;StringGrid1-&gt;RowCount + 1;
                              Form2-&gt;StringGrid1-&gt;Cells[0][Form2-&gt;StringGrid1-&gt;RowCount-1] = sr.Name;
                              Form2-&gt;StringGrid1-&gt;Cells[1][Form2-&gt;StringGrid1-&gt;RowCount-1] = IntToStr(sr.Size);

                      }
                }

    } while (FindNext(sr) == 0);
    FindClose(sr);
  }
}

void __fastcall TForm2::Button1Click(TObject *Sender)
{
StringGrid1-&gt;RowCount = 1;
StringGrid1-&gt;RowCount = 0;
suche(Edit1-&gt;Text);
}
</code></pre>
<p>ein ausschnitt aus meinem c++ quelltext..ihr seht ich schreibe das ausgelesene erst in eine ListBox und dann wird es aus der ListBox in eine .txt Datei gespeichert..<br />
Das möchte ich aber umgehen..ich möchte das das Programm alle gefundenen Daten SOFORT in eine .txt Datei schreibt..</p>
<p>könntet ihr mir helfen??<br />
DANKE</p>
]]></description><link>https://www.c-plusplus.net/forum/post/815213</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815213</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 23 Jun 2005 05:13:25 GMT</pubDate></item><item><title><![CDATA[Reply to frage: wie kann ich einen Text direkt in eine .txt Datei speicerhn OHNE ihn vorher z.B in eine ListBox zu schreiben aus on Thu, 23 Jun 2005 05:20:23 GMT]]></title><description><![CDATA[<p>Hallo guten Morgen,<br />
du kannst auch mit fopen, fread und fwrite arbeiten dann kannst du Zeile für Zeile in eine Datei schreiben.</p>
<p>evi48</p>
]]></description><link>https://www.c-plusplus.net/forum/post/815216</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815216</guid><dc:creator><![CDATA[evi48]]></dc:creator><pubDate>Thu, 23 Jun 2005 05:20:23 GMT</pubDate></item><item><title><![CDATA[Reply to frage: wie kann ich einen Text direkt in eine .txt Datei speicerhn OHNE ihn vorher z.B in eine ListBox zu schreiben aus on Thu, 23 Jun 2005 05:24:46 GMT]]></title><description><![CDATA[<p>ok dankeschön hast du vielleicht auch nen kleines Beispiel für fwrite..wie ich das am besten Anwende..??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/815217</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815217</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 23 Jun 2005 05:24:46 GMT</pubDate></item><item><title><![CDATA[Reply to frage: wie kann ich einen Text direkt in eine .txt Datei speicerhn OHNE ihn vorher z.B in eine ListBox zu schreiben aus on Thu, 23 Jun 2005 05:34:43 GMT]]></title><description><![CDATA[<p>Bitte auch mal die <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39469-and-highlight-is-fstream.html" rel="nofollow">C++ - FAQ</a> durchschauen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/815223</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815223</guid><dc:creator><![CDATA[evilissimo]]></dc:creator><pubDate>Thu, 23 Jun 2005 05:34:43 GMT</pubDate></item><item><title><![CDATA[Reply to frage: wie kann ich einen Text direkt in eine .txt Datei speicerhn OHNE ihn vorher z.B in eine ListBox zu schreiben aus on Thu, 23 Jun 2005 05:35:19 GMT]]></title><description><![CDATA[<p>evi48 schrieb:</p>
<blockquote>
<p>Hallo guten Morgen,<br />
du kannst auch mit fopen, fread und fwrite arbeiten dann kannst du Zeile für Zeile in eine Datei schreiben.</p>
<p>evi48</p>
</blockquote>
<p>Warum nicht die C++ Streams? Dazu gibts auch ein Beispiel in der <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-25.html" rel="nofollow">C++ FAQ</a>. <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/815224</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815224</guid><dc:creator><![CDATA[PuppetMaster2k]]></dc:creator><pubDate>Thu, 23 Jun 2005 05:35:19 GMT</pubDate></item><item><title><![CDATA[Reply to frage: wie kann ich einen Text direkt in eine .txt Datei speicerhn OHNE ihn vorher z.B in eine ListBox zu schreiben aus on Thu, 23 Jun 2005 05:37:08 GMT]]></title><description><![CDATA[<p>PuppetMaster2k schrieb:</p>
<blockquote>
<p>evi48 schrieb:</p>
<blockquote>
<p>Hallo guten Morgen,<br />
du kannst auch mit fopen, fread und fwrite arbeiten dann kannst du Zeile für Zeile in eine Datei schreiben.</p>
<p>evi48</p>
</blockquote>
<p>Warum nicht die C++ Streams? Dazu gibts auch ein Beispiel in der <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-25.html" rel="nofollow">C++ FAQ</a>. <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>eViLiSSiMo schrieb:</p>
<blockquote>
<p>Bitte auch mal die <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39469-and-highlight-is-fstream.html" rel="nofollow">C++ - FAQ</a> durchschauen</p>
</blockquote>
<p>L O L <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/815226</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815226</guid><dc:creator><![CDATA[evilissimo]]></dc:creator><pubDate>Thu, 23 Jun 2005 05:37:08 GMT</pubDate></item><item><title><![CDATA[Reply to frage: wie kann ich einen Text direkt in eine .txt Datei speicerhn OHNE ihn vorher z.B in eine ListBox zu schreiben aus on Thu, 23 Jun 2005 05:46:31 GMT]]></title><description><![CDATA[<p>Und hier ein Beispiel aus der Hilfe des C++ Builder</p>
<pre><code class="language-cpp">#include &lt;stdio.h&gt;

struct mystruct
{
  int i;
  char ch;
};

int main(void)
{
   FILE *stream;
   struct mystruct s;

   if ((stream = fopen(&quot;TEST.$$$&quot;, &quot;wb&quot;)) == NULL)  /* Öffnet Datei TEST.$$$ */
   {
      fprintf(stderr, &quot;Cannot open output file.\n&quot;);
      return 1;
   }
   s.i = 0;
   s.ch = 'A';
   fwrite(&amp;s, sizeof(s), 1, stream);  /* write struct s to file */
   fclose(stream);  /* close file */
   return 0;
}
</code></pre>
<p>Vergiss auf keinen Fall den fclose am Ende sonst sind deine gespeicherten Daten nicht mehr da.</p>
<p>evi48</p>
]]></description><link>https://www.c-plusplus.net/forum/post/815228</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815228</guid><dc:creator><![CDATA[evi48]]></dc:creator><pubDate>Thu, 23 Jun 2005 05:46:31 GMT</pubDate></item><item><title><![CDATA[Reply to frage: wie kann ich einen Text direkt in eine .txt Datei speicerhn OHNE ihn vorher z.B in eine ListBox zu schreiben aus on Thu, 23 Jun 2005 05:46:00 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">fstream f2(&quot;Datei.txt&quot;, ios::in); 
    if (!f2) 
    {   // ok. Datei existiert nicht. Neu erstellen 
        f.clear(); 
        f.open(&quot;Datei.txt&quot;, ios::out); 
        if (f.is_open()) 
        { 
            // mit Datei arbeiten 
        } 
    } 
    else 
    { 
        cout &lt;&lt; &quot;Datei existiert bereits!&quot; &lt;&lt; endl; 
    }
</code></pre>
<p>ist etwas anders..weil ich habe eine schleife..und wenn ich das so machen würde würde es nur eine Date in der Datei speichern und dann zeigt es bei jedem durchlauf &quot;Datei existiert bereits!&quot; an und da schreibt es mit nur einen DS rein..<br />
müsste vor der Schleife die überprüfung machen..<br />
und dann an der stelle:</p>
<pre><code class="language-cpp">Form2-&gt;ListBox1-&gt;Items-&gt;Add(pfad+sr.Name);
                              Form2-&gt;ListBox1-&gt;Items-&gt;SaveToFile(&quot;dateien.txt&quot;);
</code></pre>
<p>stehen..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/815230</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815230</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 23 Jun 2005 05:46:00 GMT</pubDate></item><item><title><![CDATA[Reply to frage: wie kann ich einen Text direkt in eine .txt Datei speicerhn OHNE ihn vorher z.B in eine ListBox zu schreiben aus on Thu, 23 Jun 2005 05:49:19 GMT]]></title><description><![CDATA[<p>Und das ist der Weg in C. In C++ geht das eher so:<br />
(Ungetestet)</p>
<pre><code class="language-cpp">#include &lt;fstream&gt;
void suche(AnsiString pfad , std::ofstream &amp; ofs )
{
Form2-&gt;Caption=pfad;

TSearchRec sr;
pfad += &quot;\\&quot;;
if (FindFirst(pfad + &quot;*&quot;, faAnyFile, sr) == 0)
  {
    do
    {
                if ((sr.Name != &quot;.&quot;)&amp;&amp;(sr.Name != &quot;..&quot;))
                {

                      if (sr.Attr == faDirectory)
                      {
                                suche(pfad+sr.Name,ofs);
                      }
                      else
                      {
                              ofs &lt;&lt; ( pfad + sr.Name ).c_str() &lt;&lt; std::endl;
                              Form2-&gt;StringGrid1-&gt;RowCount = Form2-&gt;StringGrid1-&gt;RowCount + 1;
                              Form2-&gt;StringGrid1-&gt;Cells[0][Form2-&gt;StringGrid1-&gt;RowCount-1] = sr.Name;
                              Form2-&gt;StringGrid1-&gt;Cells[1][Form2-&gt;StringGrid1-&gt;RowCount-1] = IntToStr(sr.Size);

                      }
                }

    } while (FindNext(sr) == 0);
    FindClose(sr);
  }
}
void __fastcall TForm2::Button1Click(TObject *Sender)
{
  std::ofstream ofs(&quot;Dateiname.txt&quot;);
  suche(Edit1-&gt;Text, ofs);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/815232</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815232</guid><dc:creator><![CDATA[evilissimo]]></dc:creator><pubDate>Thu, 23 Jun 2005 05:49:19 GMT</pubDate></item><item><title><![CDATA[Reply to frage: wie kann ich einen Text direkt in eine .txt Datei speicerhn OHNE ihn vorher z.B in eine ListBox zu schreiben aus on Thu, 23 Jun 2005 05:52:35 GMT]]></title><description><![CDATA[<p>Außerdem ist das alles Console..</p>
<pre><code class="language-cpp">PERSON Pers;
        cout &lt;&lt; &quot;Vorname: &quot;;
        cin &gt;&gt; Pers.VorName;
        cout &lt;&lt; &quot;Nachname: &quot;;
        cin &gt;&gt; Pers.NachName;
        cout &lt;&lt; &quot;TelNr: &quot;;
        cin &gt;&gt; Pers.TelNr;

        // Aktuelle Person in der Datei speichern.
        File.write((const char*)&amp;Pers, sizeof(Pers))
</code></pre>
<p>so etwas gibt es bei mir gar nicht..</p>
<p>der soll nur</p>
<pre><code class="language-cpp">pfad+sr.Name
</code></pre>
<p>in die .txt datei schreiben</p>
]]></description><link>https://www.c-plusplus.net/forum/post/815236</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815236</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 23 Jun 2005 05:52:35 GMT</pubDate></item><item><title><![CDATA[Reply to frage: wie kann ich einen Text direkt in eine .txt Datei speicerhn OHNE ihn vorher z.B in eine ListBox zu schreiben aus on Thu, 23 Jun 2005 05:56:46 GMT]]></title><description><![CDATA[<p>[C++ Error] Unit2.cpp(35): E2193 Too few parameters in call to 'suche(AnsiString,_STL::ofstream &amp;)'</p>
<p>???</p>
]]></description><link>https://www.c-plusplus.net/forum/post/815239</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815239</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 23 Jun 2005 05:56:46 GMT</pubDate></item><item><title><![CDATA[Reply to frage: wie kann ich einen Text direkt in eine .txt Datei speicerhn OHNE ihn vorher z.B in eine ListBox zu schreiben aus on Thu, 23 Jun 2005 05:59:25 GMT]]></title><description><![CDATA[<p>Hast du dir mal Button1Click angeschaut?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/815240</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815240</guid><dc:creator><![CDATA[evilissimo]]></dc:creator><pubDate>Thu, 23 Jun 2005 05:59:25 GMT</pubDate></item><item><title><![CDATA[Reply to frage: wie kann ich einen Text direkt in eine .txt Datei speicerhn OHNE ihn vorher z.B in eine ListBox zu schreiben aus on Thu, 23 Jun 2005 06:02:08 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">void __fastcall TForm2::Button1Click(TObject *Sender)
{
StringGrid1-&gt;RowCount = 1;
StringGrid1-&gt;RowCount = 0;
std::ofstream ofs(&quot;dateien.txt&quot;);
suche(Edit1-&gt;Text, ofs);
}
</code></pre>
<p>Der Fehler ist in dieser Zeile:</p>
<pre><code class="language-cpp">if (sr.Attr == faDirectory)
                      {
                                suche(pfad+sr.Name);
                      }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/815241</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815241</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 23 Jun 2005 06:02:08 GMT</pubDate></item><item><title><![CDATA[Reply to frage: wie kann ich einen Text direkt in eine .txt Datei speicerhn OHNE ihn vorher z.B in eine ListBox zu schreiben aus on Thu, 23 Jun 2005 06:06:51 GMT]]></title><description><![CDATA[<p>ok hab den fehler!!</p>
<p>Vielen Dank für eure Hilfe ^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/815246</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815246</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 23 Jun 2005 06:06:51 GMT</pubDate></item></channel></rss>