<?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[Programm funktioniert nur mit kleiner Datei]]></title><description><![CDATA[<p>Hi,ich hab mir ein &quot;verschlüsselungs&quot; Programm geschrieben,das nicht jeder meine Dateien anschauen kann:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;
using namespace std;

char code_byte(char);
char decode_byte(char);
void code_file(char* );
void decode_file(char* );

int main(int argc,char* argv[])
{
 if (argv[2][0] == 'c' )
  {
   code_file(argv[1]);
  }

 if (argv[2][0] == 'd' )
  {
   decode_file(argv[1]);
  }

return 0;
}

void code_file(char* file_name)
{
 char byte,buffer[1000000];
 int counter ;

 fstream file(file_name,ios::in); 

 for(counter=0;!file.eof();++counter ) 
  {
   file.get(byte);
   if (!file.eof())
   {
    buffer[counter]=code_byte(byte);
   } 
  }   

 counter -= 2;

 file.close();     

 fstream file2(file_name,ios::out); 

 for (int for_c = 0;for_c &lt; counter+1;++for_c)
    {
    file2 &lt;&lt; buffer[for_c];
    }

}

void decode_file(char* file_name)
{
 char byte,buffer[1000000];
 int counter ;

 fstream file(file_name,ios::in); 

 for(counter=0;!file.eof();++counter ) 
  {
   file.get(byte);
   if (!file.eof())
   {
    buffer[counter]=decode_byte(byte);
   } 
  }   

 counter -= 2;

 file.close();     

 fstream file2(file_name,ios::out); 

 for (int for_c = 0;for_c &lt; counter+1;++for_c)
    {
    file2 &lt;&lt; buffer[for_c];
    }

}

char code_byte(char zeichen)
{
 zeichen += 1;
 return zeichen;
}

char decode_byte(char zeichen)
{

 zeichen -= 1;
 return zeichen;
}
</code></pre>
<p>Das Funktioniert aber nur bei kleineren Dateien ,wegen</p>
<pre><code class="language-cpp">char byte,buffer[1000000];
</code></pre>
<p>Dazu meine Frage:Wie kann ich den Buffer immer so viel Byte groß machen das ich auch große Dateien unkenntlich machen kann?Muss ich vielleicht auf ne Datei auslagern,anstatt auf ein Char Array?</p>
<p>Danke im voraus,<br />
Xalon</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/124603/programm-funktioniert-nur-mit-kleiner-datei</link><generator>RSS for Node</generator><lastBuildDate>Sun, 23 Aug 2026 23:42:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/124603.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 29 Oct 2005 10:21:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Programm funktioniert nur mit kleiner Datei on Sat, 29 Oct 2005 10:21:17 GMT]]></title><description><![CDATA[<p>Hi,ich hab mir ein &quot;verschlüsselungs&quot; Programm geschrieben,das nicht jeder meine Dateien anschauen kann:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;
using namespace std;

char code_byte(char);
char decode_byte(char);
void code_file(char* );
void decode_file(char* );

int main(int argc,char* argv[])
{
 if (argv[2][0] == 'c' )
  {
   code_file(argv[1]);
  }

 if (argv[2][0] == 'd' )
  {
   decode_file(argv[1]);
  }

return 0;
}

void code_file(char* file_name)
{
 char byte,buffer[1000000];
 int counter ;

 fstream file(file_name,ios::in); 

 for(counter=0;!file.eof();++counter ) 
  {
   file.get(byte);
   if (!file.eof())
   {
    buffer[counter]=code_byte(byte);
   } 
  }   

 counter -= 2;

 file.close();     

 fstream file2(file_name,ios::out); 

 for (int for_c = 0;for_c &lt; counter+1;++for_c)
    {
    file2 &lt;&lt; buffer[for_c];
    }

}

void decode_file(char* file_name)
{
 char byte,buffer[1000000];
 int counter ;

 fstream file(file_name,ios::in); 

 for(counter=0;!file.eof();++counter ) 
  {
   file.get(byte);
   if (!file.eof())
   {
    buffer[counter]=decode_byte(byte);
   } 
  }   

 counter -= 2;

 file.close();     

 fstream file2(file_name,ios::out); 

 for (int for_c = 0;for_c &lt; counter+1;++for_c)
    {
    file2 &lt;&lt; buffer[for_c];
    }

}

char code_byte(char zeichen)
{
 zeichen += 1;
 return zeichen;
}

char decode_byte(char zeichen)
{

 zeichen -= 1;
 return zeichen;
}
</code></pre>
<p>Das Funktioniert aber nur bei kleineren Dateien ,wegen</p>
<pre><code class="language-cpp">char byte,buffer[1000000];
</code></pre>
<p>Dazu meine Frage:Wie kann ich den Buffer immer so viel Byte groß machen das ich auch große Dateien unkenntlich machen kann?Muss ich vielleicht auf ne Datei auslagern,anstatt auf ein Char Array?</p>
<p>Danke im voraus,<br />
Xalon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/903260</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/903260</guid><dc:creator><![CDATA[Xalon]]></dc:creator><pubDate>Sat, 29 Oct 2005 10:21:17 GMT</pubDate></item><item><title><![CDATA[Reply to Programm funktioniert nur mit kleiner Datei on Sat, 29 Oct 2005 10:31:05 GMT]]></title><description><![CDATA[<p>Hast du mal versucht die Groesse der Datei auszulesen und das dann einzusetzen?<br />
Hat auch den Vorteil dass immer nur das reserviert wird, was du gerade brauchst!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/903265</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/903265</guid><dc:creator><![CDATA[moe szyslak]]></dc:creator><pubDate>Sat, 29 Oct 2005 10:31:05 GMT</pubDate></item><item><title><![CDATA[Reply to Programm funktioniert nur mit kleiner Datei on Sat, 29 Oct 2005 10:35:16 GMT]]></title><description><![CDATA[<p>Datei stückchenweise einlesen und kodieren?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/903271</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/903271</guid><dc:creator><![CDATA[????????????]]></dc:creator><pubDate>Sat, 29 Oct 2005 10:35:16 GMT</pubDate></item><item><title><![CDATA[Reply to Programm funktioniert nur mit kleiner Datei on Sat, 29 Oct 2005 10:38:34 GMT]]></title><description><![CDATA[<p>moe szyslak schrieb:</p>
<blockquote>
<p>Hast du mal versucht die Groesse der Datei auszulesen und das dann einzusetzen?<br />
Hat auch den Vorteil dass immer nur das reserviert wird, was du gerade brauchst!</p>
</blockquote>
<p>Weßt du zufällig wie die Funktion heißt ? <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>
<p>Xalon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/903273</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/903273</guid><dc:creator><![CDATA[Xalon]]></dc:creator><pubDate>Sat, 29 Oct 2005 10:38:34 GMT</pubDate></item><item><title><![CDATA[Reply to Programm funktioniert nur mit kleiner Datei on Sat, 29 Oct 2005 11:15:36 GMT]]></title><description><![CDATA[<p>Na, ich wurde das so machen:</p>
<pre><code class="language-cpp">#include &lt;sys/types.h&gt;
#include &lt;sys/stat.h&gt;
#include &lt;iostream&gt;

int main( int argc, char **argv )
{
	struct stat buf;
	int result;
	result = stat( argv[1], &amp;buf );

	if( result == 0 )
		std::cout &lt;&lt; buf.st_size &lt;&lt; std::endl;

	return 0;
}
</code></pre>
<p>Die Datei stueckienweise Einlesen klingt aber auch nicht schlecht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/903292</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/903292</guid><dc:creator><![CDATA[moe szyslak]]></dc:creator><pubDate>Sat, 29 Oct 2005 11:15:36 GMT</pubDate></item><item><title><![CDATA[Reply to Programm funktioniert nur mit kleiner Datei on Sat, 29 Oct 2005 11:15:00 GMT]]></title><description><![CDATA[<p>fseek()/ftell() könnte da weiterhelfen - ansonsten könntest du auch einen vector&lt;&gt; verwenden und die Daten mit &quot;copy(istream_iterator&lt;char&gt;(file),istream_iterator&lt;char&gt;(),back_inserter(myvector));&quot; dort einlesen (der vector wächst mit, wenn es benötigt wird).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/903296</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/903296</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Sat, 29 Oct 2005 11:15:00 GMT</pubDate></item><item><title><![CDATA[Reply to Programm funktioniert nur mit kleiner Datei on Sat, 29 Oct 2005 12:01:44 GMT]]></title><description><![CDATA[<p>Ok,danke euch <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>
<p>Xalon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/903327</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/903327</guid><dc:creator><![CDATA[Xalon]]></dc:creator><pubDate>Sat, 29 Oct 2005 12:01:44 GMT</pubDate></item></channel></rss>