<?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[fstream]]></title><description><![CDATA[<p>Hat jemand eine Idee, warum das hier nicht funktioniert?</p>
<pre><code class="language-cpp">bool convert(const char* source, const char* destination, unsigned long key)
{
   if(!source || !destination)
      return(false);

   std::fstream         sFile(source,      std::ios::in);
   std::fstream         dFile(destination, std::ios::out | std::ios::app);
   unsigned long        bufferSize      = 0;
   char*                buffer          = 0;

      // source file dosn't exist?
   if(!sFile.is_open())
      return(false);

      // destination file exist?
   if(dFile.is_open())
      return(false);

   //   // destionation file dosn't exist, just open or create a file
   //dFile.close();
   //dFile.open(destination, std::ios::out | std::ios::app);

      // it is time to find out the lenght of the file
    sFile.seekg(0, std::ios_base::end);
    bufferSize = std::streamoff(sFile.tellg());
    sFile.seekg(0, std::ios_base::beg);

      // allocate the buffer
   buffer = new(char[bufferSize + 1]);

   sFile.read(buffer, bufferSize);
   buffer[bufferSize] = '\0';

   std::cout &lt;&lt; bufferSize;
   std::cout &lt;&lt; buffer;

   dFile.write(buffer, bufferSize);

   // !!!!!!
   delete[](buffer);

   return(true);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/159882/fstream</link><generator>RSS for Node</generator><lastBuildDate>Fri, 11 Sep 2026 03:37:20 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/159882.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 19 Sep 2006 18:34:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to fstream on Tue, 19 Sep 2006 18:34:36 GMT]]></title><description><![CDATA[<p>Hat jemand eine Idee, warum das hier nicht funktioniert?</p>
<pre><code class="language-cpp">bool convert(const char* source, const char* destination, unsigned long key)
{
   if(!source || !destination)
      return(false);

   std::fstream         sFile(source,      std::ios::in);
   std::fstream         dFile(destination, std::ios::out | std::ios::app);
   unsigned long        bufferSize      = 0;
   char*                buffer          = 0;

      // source file dosn't exist?
   if(!sFile.is_open())
      return(false);

      // destination file exist?
   if(dFile.is_open())
      return(false);

   //   // destionation file dosn't exist, just open or create a file
   //dFile.close();
   //dFile.open(destination, std::ios::out | std::ios::app);

      // it is time to find out the lenght of the file
    sFile.seekg(0, std::ios_base::end);
    bufferSize = std::streamoff(sFile.tellg());
    sFile.seekg(0, std::ios_base::beg);

      // allocate the buffer
   buffer = new(char[bufferSize + 1]);

   sFile.read(buffer, bufferSize);
   buffer[bufferSize] = '\0';

   std::cout &lt;&lt; bufferSize;
   std::cout &lt;&lt; buffer;

   dFile.write(buffer, bufferSize);

   // !!!!!!
   delete[](buffer);

   return(true);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1140624</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140624</guid><dc:creator><![CDATA[hlkhg]]></dc:creator><pubDate>Tue, 19 Sep 2006 18:34:36 GMT</pubDate></item><item><title><![CDATA[Reply to fstream on Tue, 19 Sep 2006 18:39:07 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Was genau ist denn dein Problem?<br />
Du hast hier ein paar Klammern zuviel</p>
<pre><code class="language-cpp">buffer = new char[bufferSize + 1];

   // !!!!!!
   delete[] buffer;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1140626</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140626</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Tue, 19 Sep 2006 18:39:07 GMT</pubDate></item><item><title><![CDATA[Reply to fstream on Tue, 19 Sep 2006 18:40:33 GMT]]></title><description><![CDATA[<p>Es funktioniert einfach gar nichts, BufferSize ist lehr, buffer ist lehr...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1140627</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140627</guid><dc:creator><![CDATA[hlkhg]]></dc:creator><pubDate>Tue, 19 Sep 2006 18:40:33 GMT</pubDate></item><item><title><![CDATA[Reply to fstream on Tue, 19 Sep 2006 18:46:29 GMT]]></title><description><![CDATA[<p>Aber in der Source Datei steht was....</p>
<p>aus der main:</p>
<pre><code class="language-cpp">encrypt(&quot;test.txt&quot;, &quot;1.txt&quot;, 2);
</code></pre>
<p>test.txt:</p>
<blockquote>
<p>1234567abcdef</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1140633</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140633</guid><dc:creator><![CDATA[hlkhg]]></dc:creator><pubDate>Tue, 19 Sep 2006 18:46:29 GMT</pubDate></item><item><title><![CDATA[Reply to fstream on Tue, 19 Sep 2006 19:00:16 GMT]]></title><description><![CDATA[<p>Ich kann hier keinen Fehler finden. Bei mir funktioniert das.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1140639</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140639</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Tue, 19 Sep 2006 19:00:16 GMT</pubDate></item><item><title><![CDATA[Reply to fstream on Tue, 19 Sep 2006 19:06:00 GMT]]></title><description><![CDATA[<p>bei mir aber nicht, ich nutze BcB 6. Bei mir legt der immer wieder nur eine leere Datei an.</p>
<p>int main(int argc, char* argv[])<br />
{<br />
if(encrypt(&quot;test.txt&quot;, &quot;h.txt&quot;, 2))<br />
std::cout &lt;&lt; &quot;Error&quot;;<br />
else<br />
std::cout &lt;&lt; &quot;Success&quot;;</p>
<p>std::cin.get();</p>
<p>return 0;<br />
}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1140644</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140644</guid><dc:creator><![CDATA[hlkhg]]></dc:creator><pubDate>Tue, 19 Sep 2006 19:06:00 GMT</pubDate></item><item><title><![CDATA[Reply to fstream on Tue, 19 Sep 2006 19:06:53 GMT]]></title><description><![CDATA[<p>wird zwar ein Success ausgeben aber sonst tut sich nichts.</p>
<p>Ich bin so nicht der BCB Fan, muss ihn aber leider fürs die Schule nutzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1140645</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140645</guid><dc:creator><![CDATA[hlkhg]]></dc:creator><pubDate>Tue, 19 Sep 2006 19:06:53 GMT</pubDate></item><item><title><![CDATA[Reply to fstream on Tue, 19 Sep 2006 19:15:03 GMT]]></title><description><![CDATA[<p>irendwie zeigt der nur success an, auch wenn die source datei nicht existert...</p>
<p>Langsam verzweifel ich</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1140650</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140650</guid><dc:creator><![CDATA[hlkhg]]></dc:creator><pubDate>Tue, 19 Sep 2006 19:15:03 GMT</pubDate></item><item><title><![CDATA[Reply to fstream on Tue, 19 Sep 2006 19:18:01 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Was ist denn jetzt wieder dieses encrypt? Das gleiche wie convert? Am BCB liegt das hier mit Sicherheit nicht.</p>
<p>Stop!!<br />
Mach mal ein ! vor das encrypt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1140652</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140652</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Tue, 19 Sep 2006 19:18:01 GMT</pubDate></item><item><title><![CDATA[Reply to fstream on Tue, 19 Sep 2006 19:16:05 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">//---------------------------------------------------------------------------

#pragma hdrstop

#include &lt;iostream&gt;
#include &lt;Windows.h&gt;
#include &lt;fstream&gt;

bool encrypt(const char* source, const char* destination, unsigned long key)
{
   if(!source || !destination)
      return(false);

   std::fstream         sFile(source,      std::ios::in);
   std::fstream         dFile(destination, std::ios::out | std::ios::app);
   unsigned long        bufferSize      = 0;
   char*                buffer          = 0;

      // source file dosn't exist?
   if(!sFile.is_open())
      return(false);

      // destination file exist?
   if(dFile.is_open())
      return(false);

   //   // destionation file dosn't exist, just open or create a file
   //dFile.close();
   //dFile.open(destination, std::ios::out | std::ios::app);

      // it is time to find out the lenght of the file
    sFile.seekg(0, std::ios_base::end);
    bufferSize = std::streamoff(sFile.tellg());
    sFile.seekg(0, std::ios_base::beg);

      // allocate the buffer
   buffer = new char[bufferSize + 1];

   sFile.read(buffer, bufferSize);
   buffer[bufferSize] = '\0';

   std::cout &lt;&lt; bufferSize;
   std::cout &lt;&lt; buffer;

   dFile.write(buffer, bufferSize);

      // !!!!!!
   delete[] buffer;
   buffer = 0;

   return(true);
}
//---------------------------------------------------------------------------

#pragma argsused
int main(int argc, char* argv[])
{
   if(encrypt(&quot;a.txt&quot;, &quot;h.txt&quot;, 2) == true)
      std::cout &lt;&lt; &quot;Error&quot;;
   else
      std::cout &lt;&lt; &quot;Success&quot;;

   std::cin.get();

  return 0;
}
//---------------------------------------------------------------------------
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1140653</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140653</guid><dc:creator><![CDATA[hlkhg]]></dc:creator><pubDate>Tue, 19 Sep 2006 19:16:05 GMT</pubDate></item><item><title><![CDATA[Reply to fstream on Tue, 19 Sep 2006 19:20:54 GMT]]></title><description><![CDATA[<p>oder so <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>
<pre><code class="language-cpp">#pragma argsused
int main(int argc, char* argv[])
{
   if(encrypt(&quot;a.txt&quot;, &quot;h.txt&quot;, 2) == true)
      std::cout &lt;&lt; &quot;Success&quot;;
   else
      std::cout &lt;&lt; &quot;Error&quot;;

   std::cin.get();

  return 0;
}
//---------------------------------------------------------------------------
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1140658</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140658</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Tue, 19 Sep 2006 19:20:54 GMT</pubDate></item><item><title><![CDATA[Reply to fstream on Tue, 19 Sep 2006 19:21:33 GMT]]></title><description><![CDATA[<p>Ich hatte die Funktion nur erst convert genannt, da sie noch nicht fertig ist und damit es nicht zu Verwirrung führt.</p>
<p>Dein Download-Link #1: <a href="http://rapidshare.de/files/33710336/Crypth.rar.html" rel="nofollow">http://rapidshare.de/files/33710336/Crypth.rar.html</a><br />
Dein Lösch-Link #1: <a href="http://rapidshare.de/files/33710336/Crypth.rar?killcode=1577951015" rel="nofollow">http://rapidshare.de/files/33710336/Crypth.rar?killcode=1577951015</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1140660</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140660</guid><dc:creator><![CDATA[hlkhg]]></dc:creator><pubDate>Tue, 19 Sep 2006 19:21:33 GMT</pubDate></item><item><title><![CDATA[Reply to fstream on Tue, 19 Sep 2006 19:26:49 GMT]]></title><description><![CDATA[<p>Ich habe gerade etwas zu viel von meinen Projektdateien gelöscht, aber ich hatte eine Konsolenexperten Anwendung genommen(ohne den ganzen Schnickschnak, nur C++)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1140667</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140667</guid><dc:creator><![CDATA[hlkhg]]></dc:creator><pubDate>Tue, 19 Sep 2006 19:26:49 GMT</pubDate></item><item><title><![CDATA[Reply to fstream on Tue, 19 Sep 2006 19:41:34 GMT]]></title><description><![CDATA[<p>Braunstein schrieb:</p>
<blockquote>
<p>Hallo,</p>
<p>Was ist denn jetzt wieder dieses encrypt? Das gleiche wie convert? Am BCB liegt das hier mit Sicherheit nicht.</p>
<p>Stop!!<br />
Mach mal ein ! vor das encrypt.</p>
</blockquote>
<p>Dumemr Schusselfehler, nun kommt aber trotzdem immer eine Error Meldung</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1140681</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140681</guid><dc:creator><![CDATA[hlkhg]]></dc:creator><pubDate>Tue, 19 Sep 2006 19:41:34 GMT</pubDate></item><item><title><![CDATA[Reply to fstream on Tue, 19 Sep 2006 19:57:06 GMT]]></title><description><![CDATA[<p>Das Problem ist das hier</p>
<pre><code class="language-cpp">if(dFile.is_open())
   return(false);
</code></pre>
<p>Da du die Ausgabedatei vorher öffnest, ist sie an dieser Stelle immer offen und das Ergebnis somit false. Lösch das da einfach oder mach auch hier ein ! davor.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1140688</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140688</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Tue, 19 Sep 2006 19:57:06 GMT</pubDate></item><item><title><![CDATA[Reply to fstream on Wed, 20 Sep 2006 15:13:07 GMT]]></title><description><![CDATA[<p>Ok, aber jetzt gibt es schion wieder ein neues Problem...</p>
<pre><code class="language-cpp">bool encrypt(const char* source, const char* destination, unsigned long key)
{
   if(!source || !destination)
      return(false);

   std::fstream         sFile(source,      std::ios::in);
   std::fstream         dFile(destination, std::ios::out | std::ios::trunc);
   unsigned long        bufferSize      = 0;
   char*                buffer          = 0;

      // source file dosn't exist?
   if(!sFile.is_open())
      return(false);

      // it is time to find out the lenght of the file
    sFile.seekg(0, std::ios_base::end);
    bufferSize = std::streamoff(sFile.tellg());
    sFile.seekg(0, std::ios_base::beg);

      // allocate the buffer
   buffer = new char[bufferSize];

   sFile.read(buffer, bufferSize);
   buffer[bufferSize] = '\0';

   dFile.write(buffer, bufferSize);

   sFile.close();
   dFile.close();

   delete[] buffer;
   buffer = 0;

   return(true);
}
</code></pre>
<p>Ich mit der Funktion(wo bis jetzt noch kein verschlüsselungsalgorithmus implentiert ist) mal eine 23Kb große exe Datei &quot;umgewandelt&quot;</p>
<p>also:</p>
<pre><code class="language-cpp">encrypt(&quot;test.exe&quot;, a.exe&quot;, 3);
</code></pre>
<p>--&gt; jedoch war die neue exe um ein paar bites größer und konnte sich nicht mehr öffnen lassen, warum? das gleiche istmir bei einem txt file passiert, was über 5K groß war...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1141267</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1141267</guid><dc:creator><![CDATA[hlkhg]]></dc:creator><pubDate>Wed, 20 Sep 2006 15:13:07 GMT</pubDate></item><item><title><![CDATA[Reply to fstream on Wed, 20 Sep 2006 16:31:04 GMT]]></title><description><![CDATA[<p>Hat keiner eine Idee? Ich wäre über eine Antwort sehr dankbar, denn langsam verzweifel ich...</p>
<p>Ich muss noch zwei Fehler korrigieren...</p>
<ol>
<li></li>
</ol>
<pre><code class="language-cpp">encrypt(&quot;test.exe&quot;, &quot;a.exe&quot;, 3);
</code></pre>
<ol start="2">
<li></li>
</ol>
<pre><code class="language-cpp">...
      // allocate the buffer
   buffer = new char[bufferSize + 1]; ////////// + 1!!!!!!!!!

   sFile.read(buffer, bufferSize);
   buffer[bufferSize] = '\0';

...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1141336</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1141336</guid><dc:creator><![CDATA[hlkhg]]></dc:creator><pubDate>Wed, 20 Sep 2006 16:31:04 GMT</pubDate></item><item><title><![CDATA[Reply to fstream on Wed, 20 Sep 2006 17:05:14 GMT]]></title><description><![CDATA[<p>hlkhg schrieb:</p>
<blockquote>
<p>--&gt; jedoch war die neue exe um ein paar bites größer und konnte sich nicht mehr öffnen lassen, warum? das gleiche istmir bei einem txt file passiert, was über 5K groß war...</p>
</blockquote>
<p>Du must <strong>ios::binary</strong> verwenden ! Bei großen Dateien must du auch noch eine Schleife mit reinbringen.</p>
<p>P.S. Warum übergibst du ein Argument &quot;key&quot; das du nie verwendest ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1141356</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1141356</guid><dc:creator><![CDATA[WoWe]]></dc:creator><pubDate>Wed, 20 Sep 2006 17:05:14 GMT</pubDate></item><item><title><![CDATA[Reply to fstream on Wed, 20 Sep 2006 17:24:20 GMT]]></title><description><![CDATA[<p>WoWe schrieb:</p>
<blockquote>
<p>hlkhg schrieb:</p>
<blockquote>
<p>--&gt; jedoch war die neue exe um ein paar bites größer und konnte sich nicht mehr öffnen lassen, warum? das gleiche istmir bei einem txt file passiert, was über 5K groß war...</p>
</blockquote>
<p>Du must <strong>ios::binary</strong> verwenden ! Bei großen Dateien must du auch noch eine Schleife mit reinbringen.</p>
<p>P.S. Warum übergibst du ein Argument &quot;key&quot; das du nie verwendest ?</p>
</blockquote>
<p>Das mit dem ios::binary erscheint mir logisch, aber was meinst du mit der Schleife?</p>
<p>Der Key kommt noch, ich brauche aber ersteinmal ein funtionierendes Grundgerüst für die Funktion.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1141369</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1141369</guid><dc:creator><![CDATA[hlkhg]]></dc:creator><pubDate>Wed, 20 Sep 2006 17:24:20 GMT</pubDate></item></channel></rss>