<?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[Caesar-Verschlüsslung]]></title><description><![CDATA[<p>Hey ich wollte eine Caesar-Verschlüsslung in C++ schreiben doch ich bekomme ganze zeit die Fehlermeldung &quot;String subscript out of Range&quot; was es heißt weiß ich doch wie löse ich das Problem?</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;

string crypt(string text,int chiffre) {
    for(unsigned int i = 0; i &lt;= text.length(); i++) {
        text[i] = text[i] + chiffre;
    }
    return text;
}

string decrypt(string text,int chiffre) {
    for(unsigned int i = 0; i &lt;= text.length(); i++) {
        text[i] = text[i] - chiffre;
    }
    return text;
}

int main()
{
    string textc = &quot;&quot;;
    string textd = &quot;&quot;;
    char input = '0';
    int chiffre = 0;
    bool exit = false;

    do{
        cout &lt;&lt; &quot;Caesar-Chiffre&quot; &lt;&lt; endl &lt;&lt; endl;
        cout &lt;&lt; &quot;&lt;1&gt; Crypt&quot; &lt;&lt; endl;
        cout &lt;&lt; &quot;&lt;2&gt; Decrypt&quot; &lt;&lt; endl;
        cout &lt;&lt; &quot;&lt;3&gt; Exit&quot; &lt;&lt; endl;
        cout &lt;&lt; endl &lt;&lt; &quot;Input : &quot;;
        cin &gt;&gt; input;

        switch(input) {
            case '1' : cout &lt;&lt; endl &lt;&lt; &quot;Text : &quot;;
                       cin &gt;&gt; textc;
                       cout &lt;&lt; endl &lt;&lt; &quot;Chiffre : &quot;;
                       cin &gt;&gt; chiffre;
                       cout &lt;&lt; endl &lt;&lt; endl &lt;&lt; crypt(textc,chiffre) &lt;&lt; endl;
                       fflush(stdin);
                       getchar();
                       break;
            case '2' : cout &lt;&lt; endl &lt;&lt; &quot;Text : &quot;;
                       cin &gt;&gt; textd;
                       cout &lt;&lt; endl &lt;&lt; &quot;Chiffre : &quot;;
                       cin &gt;&gt; chiffre;
                       cout &lt;&lt; endl &lt;&lt; endl &lt;&lt; decrypt(textd,chiffre) &lt;&lt; endl;
                       fflush(stdin);
                       getchar();
                       break;
            case '3' : exit = true;
                       break;
           default : cout &lt;&lt; endl &lt;&lt; &quot;Fuck off choose one option from the list!&quot; &lt;&lt; endl &lt;&lt; endl;
                     break;
                     }
        }while(exit == false);

    return 0;
}
</code></pre>
<p>Danke im vorraus!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/316341/caesar-verschlüsslung</link><generator>RSS for Node</generator><lastBuildDate>Thu, 30 Jul 2026 08:22:25 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/316341.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 30 Apr 2013 08:35:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Caesar-Verschlüsslung on Tue, 30 Apr 2013 08:35:38 GMT]]></title><description><![CDATA[<p>Hey ich wollte eine Caesar-Verschlüsslung in C++ schreiben doch ich bekomme ganze zeit die Fehlermeldung &quot;String subscript out of Range&quot; was es heißt weiß ich doch wie löse ich das Problem?</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;

string crypt(string text,int chiffre) {
    for(unsigned int i = 0; i &lt;= text.length(); i++) {
        text[i] = text[i] + chiffre;
    }
    return text;
}

string decrypt(string text,int chiffre) {
    for(unsigned int i = 0; i &lt;= text.length(); i++) {
        text[i] = text[i] - chiffre;
    }
    return text;
}

int main()
{
    string textc = &quot;&quot;;
    string textd = &quot;&quot;;
    char input = '0';
    int chiffre = 0;
    bool exit = false;

    do{
        cout &lt;&lt; &quot;Caesar-Chiffre&quot; &lt;&lt; endl &lt;&lt; endl;
        cout &lt;&lt; &quot;&lt;1&gt; Crypt&quot; &lt;&lt; endl;
        cout &lt;&lt; &quot;&lt;2&gt; Decrypt&quot; &lt;&lt; endl;
        cout &lt;&lt; &quot;&lt;3&gt; Exit&quot; &lt;&lt; endl;
        cout &lt;&lt; endl &lt;&lt; &quot;Input : &quot;;
        cin &gt;&gt; input;

        switch(input) {
            case '1' : cout &lt;&lt; endl &lt;&lt; &quot;Text : &quot;;
                       cin &gt;&gt; textc;
                       cout &lt;&lt; endl &lt;&lt; &quot;Chiffre : &quot;;
                       cin &gt;&gt; chiffre;
                       cout &lt;&lt; endl &lt;&lt; endl &lt;&lt; crypt(textc,chiffre) &lt;&lt; endl;
                       fflush(stdin);
                       getchar();
                       break;
            case '2' : cout &lt;&lt; endl &lt;&lt; &quot;Text : &quot;;
                       cin &gt;&gt; textd;
                       cout &lt;&lt; endl &lt;&lt; &quot;Chiffre : &quot;;
                       cin &gt;&gt; chiffre;
                       cout &lt;&lt; endl &lt;&lt; endl &lt;&lt; decrypt(textd,chiffre) &lt;&lt; endl;
                       fflush(stdin);
                       getchar();
                       break;
            case '3' : exit = true;
                       break;
           default : cout &lt;&lt; endl &lt;&lt; &quot;Fuck off choose one option from the list!&quot; &lt;&lt; endl &lt;&lt; endl;
                     break;
                     }
        }while(exit == false);

    return 0;
}
</code></pre>
<p>Danke im vorraus!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2319817</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2319817</guid><dc:creator><![CDATA[Chrome]]></dc:creator><pubDate>Tue, 30 Apr 2013 08:35:38 GMT</pubDate></item><item><title><![CDATA[Reply to Caesar-Verschlüsslung on Tue, 30 Apr 2013 08:49:39 GMT]]></title><description><![CDATA[<p>Das Problem liegt hier:</p>
<pre><code>for(unsigned int i = 0; i &lt;= text.length(); i++) {
</code></pre>
<p>Gültige Indizes sind nur 0 bis text.length()-1</p>
<p>Eine echte Caesar-Verschlüsselung ist es auch nicht, weil es passieren kann, dass bei Deinem Code keine gültigen Buchstaben rauskommen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2319824</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2319824</guid><dc:creator><![CDATA[Compuholic]]></dc:creator><pubDate>Tue, 30 Apr 2013 08:49:39 GMT</pubDate></item><item><title><![CDATA[Reply to Caesar-Verschlüsslung on Tue, 30 Apr 2013 08:49:46 GMT]]></title><description><![CDATA[<p>Chrome schrieb:</p>
<blockquote>
<pre><code class="language-cpp">for(unsigned int i = 0; i &lt;= text.length(); i++)
    for(unsigned int i = 0; i &lt;= text.length(); i++)
</code></pre>
</blockquote>
<p>text.length()+1 ist größer als text.length(). Ergo, was musst du tun? <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/2319825</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2319825</guid><dc:creator><![CDATA[out]]></dc:creator><pubDate>Tue, 30 Apr 2013 08:49:46 GMT</pubDate></item></channel></rss>