<?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[cout gibt das char array nich aus!]]></title><description><![CDATA[<p>Hallo liebe Community!<br />
Zuerst möchte ich sagen, dass das mein erster Beitrag ist, also nochmal ein herzliches Hallo!<br />
So nun zu meinem Problem:<br />
Zu einem PC-Spiel namens W(orld) o(f) T(anks) haben ein anderes WoT-Forenmitglied und ich ein Programm zur Berechnung von XP geschrieben, soweit auch kein Problem, wenn auch etwas unübersichtlich! In der Grundform funktionierte auch alles einwandfrei, bis ich denn Ausgabetext formatieren wollte, jetzt gibt das Programm an einer bestimmten Stelle den Text nicht aus! Meine Frage an auch: Warum ist das so und wie kann ich den Fehler (<strong>in Zeile 111-117</strong>) beheben?<br />
Danke schonmal im Voraus<br />
Mux</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string.h&gt;
#include &lt;iomanip&gt;

using namespace std;

const int LEN = 30;
const int anzahl = 14;

int main()
{

char *DeutscheJP[9] = {&quot;PanzerJagerI\n&quot;,&quot;MarderII\n&quot;,
                      &quot;Hetzer\n&quot;,&quot;StugIII\n&quot;,
                      &quot;JgdPzIV\n&quot;,&quot;JagdPanther\n&quot;,
                      &quot;Ferdindand\n&quot;,&quot;JagdTiger\n&quot;};
char *DeutscheP [15] = {&quot;Leichttraktor\n&quot;,&quot;PzKpfwII\n&quot;,
                      &quot;PzKpfwIIIAusfA\n&quot;,
                      &quot;PanzerIII\n&quot;,                     
                      &quot;PanzerIV\n&quot;,&quot;3601H\n&quot;,
                      &quot;TigerI\n&quot;,&quot;TigerII\n&quot;,
                      &quot;4502AusfB\n&quot;,&quot;Maus\n&quot;,
                      &quot;PanzerIII/IV\n&quot;,&quot;3001P\n&quot;,
                      &quot;3002DB\n&quot;,&quot;Panther\n&quot;,
                      };
char *DeutscheA [5] =  {&quot;Bison\n&quot;,&quot;SturmpanzerII\n&quot;,
                       &quot;Grille\n&quot;,&quot;Hummel\n&quot;
                      };
class String {
  public:
  char *s;                 // Zeichenkette
  int Xp;
  String(void)  {s=new char [20];};
}; 

        String panzer[LEN];
        String zielpanzer;
        int start,ziel;
        panzer[0].s=&quot;Leichttraktor\0&quot;; panzer[0].Xp=0;
        panzer[1].s=&quot;PzKpfwII\0&quot;; panzer[1].Xp=175;
        panzer[2].s=&quot;PzKpfwIIIAusfA\0&quot;; panzer[2].Xp=1135;
        panzer[2].Xp=panzer[2].Xp+panzer[0].Xp+panzer[1].Xp;
        panzer[3].s=&quot;PanzerIII\0&quot;; panzer[3].Xp=4235;
        panzer[3].Xp=panzer[3].Xp+panzer[2].Xp+panzer[0].Xp;
        panzer[4].s=&quot;PanzerIV\0&quot;; panzer[4].Xp=15455;
        panzer[4].Xp=panzer[4].Xp+panzer[3].Xp+panzer[0].Xp;
        panzer[5].s=&quot;3601H\0&quot;; panzer[5].Xp=29955;
        panzer[5].Xp=panzer[5].Xp+panzer[4].Xp+panzer[0].Xp;
        panzer[6].s=&quot;TigerI\0&quot;; panzer[6].Xp=54065;
        panzer[6].Xp=panzer[6].Xp+panzer[5].Xp+panzer[0].Xp;
        panzer[7].s=&quot;TigerII\0&quot;; panzer[7].Xp=120495;
        panzer[7].Xp=panzer[7].Xp+panzer[6].Xp+panzer[0].Xp;
        panzer[8].s=&quot;4502AusfB\0&quot;; panzer[8].Xp=185750;
        panzer[8].Xp=panzer[8].Xp+panzer[7].Xp+panzer[0].Xp;
        panzer[9].s=&quot;Maus\0&quot;; panzer[9].Xp=279870;
        panzer[9].Xp=panzer[9].Xp+panzer[8].Xp+panzer[0].Xp;
        panzer[10].s=&quot;PanzerIII/IV\0&quot;; panzer[10].Xp=15455;
        panzer[10].Xp=panzer[10].Xp+panzer[3].Xp+panzer[0].Xp;
        panzer[11].s=&quot;3001P\0&quot;; panzer[11].Xp=29635;
        panzer[11].Xp=panzer[11].Xp+panzer[10].Xp+panzer[0].Xp;
        panzer[12].s=&quot;3002DB\0&quot;; panzer[12].Xp=41180;
        panzer[12].Xp=panzer[12].Xp+panzer[11].Xp+panzer[0].Xp;
        panzer[13].s=&quot;Panther\0&quot;; panzer[13].Xp=99135;
        panzer[13].Xp=panzer[13].Xp+panzer[12].Xp+panzer[0].Xp;
        panzer[14].s=&quot;Bison\0&quot;; panzer[14].Xp=155;
        panzer[15].s=&quot;SturmpanzerII\0&quot;; panzer[15].Xp=3605;
        panzer[15].Xp=panzer[15].Xp+panzer[14].Xp+panzer[0].Xp;
        panzer[16].s=&quot;Grille\0&quot;; panzer[16].Xp=14445;
        panzer[16].Xp=panzer[16].Xp+panzer[15].Xp+panzer[0].Xp;
        panzer[17].s=&quot;Hummel\0&quot;; panzer[17].Xp=48190;
        panzer[17].Xp=panzer[17].Xp+panzer[16].Xp+panzer[0].Xp;
        panzer[18].s=&quot;PanzerJagerI\0&quot;; panzer[18].Xp=185;
        panzer[19].s=&quot;MarderII\0&quot;; panzer[19].Xp=1425;
        panzer[19].Xp=panzer[19].Xp+panzer[18].Xp+panzer[0].Xp;
        panzer[20].s=&quot;Hetzer\0&quot;; panzer[20].Xp=5145;
        panzer[20].Xp=panzer[20].Xp+panzer[19].Xp+panzer[0].Xp;
        panzer[21].s=&quot;StugIII\0&quot;; panzer[21].Xp=12435;
        panzer[21].Xp=panzer[21].Xp+panzer[20].Xp+panzer[0].Xp;
        panzer[22].s=&quot;JgdPzIV\0&quot;; panzer[22].Xp=34785;
        panzer[22].Xp=panzer[22].Xp+panzer[21].Xp+panzer[0].Xp;
        panzer[23].s=&quot;JagdPanther\0&quot;; panzer[23].Xp=69240;
        panzer[23].Xp=panzer[23].Xp+panzer[22].Xp+panzer[0].Xp;
        panzer[24].s=&quot;Ferdindand\0&quot;; panzer[24].Xp=98630;
        panzer[24].Xp=panzer[24].Xp+panzer[23].Xp+panzer[0].Xp;
        panzer[25].s=&quot;JagdTiger\0&quot;; panzer[25].Xp=256040;
        panzer[25].Xp=panzer[25].Xp+panzer[24].Xp+panzer[0].Xp;

        cout&lt;&lt;&quot;Willkommen beim XP Calculator made by Stevie04&amp;Panzer_mux!\n\n&quot;; // Des konnt ich mir nich verkneifen ;D
        cout &lt;&lt; &quot;Deutsche Panzer:\n&quot; 
             &lt;&lt; &quot;\n***Panzer***&quot; 
             &lt;&lt; endl;
        for (int i=0; i &lt; anzahl; i++){       // Damit alles angezeigt wird
          cout.fill('/');                     // Deklaration für füll zeichen
          cout &lt;&lt; setiosflags(ios::right)     // Rechtsbündige-Schrift
               &lt;&lt; setw(15) &lt;&lt; DeutscheP  [i]  //Das die Wörter bis 15 Zeichen mit dem Zeichen / aufgefüllt werden 
               &lt;&lt; resetiosflags(ios::right)
               &lt;&lt; flush;
          };
        cout &lt;&lt; &quot;\n***Artillerie***&quot; &lt;&lt; endl;

        for (int i=0; i &lt; 9; i++) {
          cout.fill('/');
          cout &lt;&lt; setiosflags(ios::right)
               &lt;&lt; setw(15) &lt;&lt; DeutscheA [i]
               &lt;&lt; resetiosflags(ios::right)
               &lt;&lt; flush;
          };

        cout &lt;&lt;&quot;\n***JagdPanzer***\n&quot; &lt;&lt; endl;  
        for (int i =0; i&lt;14;i++)  {
          cout.fill('/');
          cout &lt;&lt; setiosflags(ios::right)
               &lt;&lt; setw(15) &lt;&lt; DeutscheJP [i]
               &lt;&lt; resetiosflags(ios::right)
               &lt;&lt; flush;
          };

        cout&lt;&lt;&quot;\nBitte geben Sie den Namen Ihres Startpanzers aus der oberen Liste ein:&quot; &quot;\n&quot;&lt;&lt; flush;
        cin&gt;&gt; zielpanzer.s;

        for (int i=0;i&lt;LEN;i++)//startpanzer aussuchen
                if(strncmp(panzer[i].s,zielpanzer.s,20)==0)
                        {start=i; break;}
        cout&lt;&lt;&quot;Bitte geben Sie den Namen Ihres Zielpanzers aus der oberen Liste ein:&quot; &quot;\n&quot;;
        cin&gt;&gt; zielpanzer.s;
        for (int i=0;i&lt;LEN;i++)//startpanzer aussuchen
                if(strncmp(panzer[i].s,zielpanzer.s,20)==0)
                        {ziel=i;break;}
        panzer[3].Xp=panzer[start].Xp-panzer[ziel].Xp;
        cout&lt;&lt; &quot;Ergebnis:&quot; &lt;&lt; panzer[3].Xp*(-1) &lt;&lt; &quot;XP&quot; &quot;\n&quot;;
        cin.clear();
cin.ignore(cin.rdbuf()-&gt;in_avail());
cin.get(); 
}
</code></pre>
<p>Gemeint is das Char Array: DeutscheJP... probierts doch mal aus <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="🙂"
    /> (WIn 7 müsste probleme machen. wenn ja dann die header StdAfx.h einbinden!)</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/280395/cout-gibt-das-char-array-nich-aus</link><generator>RSS for Node</generator><lastBuildDate>Mon, 24 Aug 2026 03:08:06 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/280395.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 14 Jan 2011 20:06:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to cout gibt das char array nich aus! on Fri, 14 Jan 2011 20:17:22 GMT]]></title><description><![CDATA[<p>Hallo liebe Community!<br />
Zuerst möchte ich sagen, dass das mein erster Beitrag ist, also nochmal ein herzliches Hallo!<br />
So nun zu meinem Problem:<br />
Zu einem PC-Spiel namens W(orld) o(f) T(anks) haben ein anderes WoT-Forenmitglied und ich ein Programm zur Berechnung von XP geschrieben, soweit auch kein Problem, wenn auch etwas unübersichtlich! In der Grundform funktionierte auch alles einwandfrei, bis ich denn Ausgabetext formatieren wollte, jetzt gibt das Programm an einer bestimmten Stelle den Text nicht aus! Meine Frage an auch: Warum ist das so und wie kann ich den Fehler (<strong>in Zeile 111-117</strong>) beheben?<br />
Danke schonmal im Voraus<br />
Mux</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string.h&gt;
#include &lt;iomanip&gt;

using namespace std;

const int LEN = 30;
const int anzahl = 14;

int main()
{

char *DeutscheJP[9] = {&quot;PanzerJagerI\n&quot;,&quot;MarderII\n&quot;,
                      &quot;Hetzer\n&quot;,&quot;StugIII\n&quot;,
                      &quot;JgdPzIV\n&quot;,&quot;JagdPanther\n&quot;,
                      &quot;Ferdindand\n&quot;,&quot;JagdTiger\n&quot;};
char *DeutscheP [15] = {&quot;Leichttraktor\n&quot;,&quot;PzKpfwII\n&quot;,
                      &quot;PzKpfwIIIAusfA\n&quot;,
                      &quot;PanzerIII\n&quot;,                     
                      &quot;PanzerIV\n&quot;,&quot;3601H\n&quot;,
                      &quot;TigerI\n&quot;,&quot;TigerII\n&quot;,
                      &quot;4502AusfB\n&quot;,&quot;Maus\n&quot;,
                      &quot;PanzerIII/IV\n&quot;,&quot;3001P\n&quot;,
                      &quot;3002DB\n&quot;,&quot;Panther\n&quot;,
                      };
char *DeutscheA [5] =  {&quot;Bison\n&quot;,&quot;SturmpanzerII\n&quot;,
                       &quot;Grille\n&quot;,&quot;Hummel\n&quot;
                      };
class String {
  public:
  char *s;                 // Zeichenkette
  int Xp;
  String(void)  {s=new char [20];};
}; 

        String panzer[LEN];
        String zielpanzer;
        int start,ziel;
        panzer[0].s=&quot;Leichttraktor\0&quot;; panzer[0].Xp=0;
        panzer[1].s=&quot;PzKpfwII\0&quot;; panzer[1].Xp=175;
        panzer[2].s=&quot;PzKpfwIIIAusfA\0&quot;; panzer[2].Xp=1135;
        panzer[2].Xp=panzer[2].Xp+panzer[0].Xp+panzer[1].Xp;
        panzer[3].s=&quot;PanzerIII\0&quot;; panzer[3].Xp=4235;
        panzer[3].Xp=panzer[3].Xp+panzer[2].Xp+panzer[0].Xp;
        panzer[4].s=&quot;PanzerIV\0&quot;; panzer[4].Xp=15455;
        panzer[4].Xp=panzer[4].Xp+panzer[3].Xp+panzer[0].Xp;
        panzer[5].s=&quot;3601H\0&quot;; panzer[5].Xp=29955;
        panzer[5].Xp=panzer[5].Xp+panzer[4].Xp+panzer[0].Xp;
        panzer[6].s=&quot;TigerI\0&quot;; panzer[6].Xp=54065;
        panzer[6].Xp=panzer[6].Xp+panzer[5].Xp+panzer[0].Xp;
        panzer[7].s=&quot;TigerII\0&quot;; panzer[7].Xp=120495;
        panzer[7].Xp=panzer[7].Xp+panzer[6].Xp+panzer[0].Xp;
        panzer[8].s=&quot;4502AusfB\0&quot;; panzer[8].Xp=185750;
        panzer[8].Xp=panzer[8].Xp+panzer[7].Xp+panzer[0].Xp;
        panzer[9].s=&quot;Maus\0&quot;; panzer[9].Xp=279870;
        panzer[9].Xp=panzer[9].Xp+panzer[8].Xp+panzer[0].Xp;
        panzer[10].s=&quot;PanzerIII/IV\0&quot;; panzer[10].Xp=15455;
        panzer[10].Xp=panzer[10].Xp+panzer[3].Xp+panzer[0].Xp;
        panzer[11].s=&quot;3001P\0&quot;; panzer[11].Xp=29635;
        panzer[11].Xp=panzer[11].Xp+panzer[10].Xp+panzer[0].Xp;
        panzer[12].s=&quot;3002DB\0&quot;; panzer[12].Xp=41180;
        panzer[12].Xp=panzer[12].Xp+panzer[11].Xp+panzer[0].Xp;
        panzer[13].s=&quot;Panther\0&quot;; panzer[13].Xp=99135;
        panzer[13].Xp=panzer[13].Xp+panzer[12].Xp+panzer[0].Xp;
        panzer[14].s=&quot;Bison\0&quot;; panzer[14].Xp=155;
        panzer[15].s=&quot;SturmpanzerII\0&quot;; panzer[15].Xp=3605;
        panzer[15].Xp=panzer[15].Xp+panzer[14].Xp+panzer[0].Xp;
        panzer[16].s=&quot;Grille\0&quot;; panzer[16].Xp=14445;
        panzer[16].Xp=panzer[16].Xp+panzer[15].Xp+panzer[0].Xp;
        panzer[17].s=&quot;Hummel\0&quot;; panzer[17].Xp=48190;
        panzer[17].Xp=panzer[17].Xp+panzer[16].Xp+panzer[0].Xp;
        panzer[18].s=&quot;PanzerJagerI\0&quot;; panzer[18].Xp=185;
        panzer[19].s=&quot;MarderII\0&quot;; panzer[19].Xp=1425;
        panzer[19].Xp=panzer[19].Xp+panzer[18].Xp+panzer[0].Xp;
        panzer[20].s=&quot;Hetzer\0&quot;; panzer[20].Xp=5145;
        panzer[20].Xp=panzer[20].Xp+panzer[19].Xp+panzer[0].Xp;
        panzer[21].s=&quot;StugIII\0&quot;; panzer[21].Xp=12435;
        panzer[21].Xp=panzer[21].Xp+panzer[20].Xp+panzer[0].Xp;
        panzer[22].s=&quot;JgdPzIV\0&quot;; panzer[22].Xp=34785;
        panzer[22].Xp=panzer[22].Xp+panzer[21].Xp+panzer[0].Xp;
        panzer[23].s=&quot;JagdPanther\0&quot;; panzer[23].Xp=69240;
        panzer[23].Xp=panzer[23].Xp+panzer[22].Xp+panzer[0].Xp;
        panzer[24].s=&quot;Ferdindand\0&quot;; panzer[24].Xp=98630;
        panzer[24].Xp=panzer[24].Xp+panzer[23].Xp+panzer[0].Xp;
        panzer[25].s=&quot;JagdTiger\0&quot;; panzer[25].Xp=256040;
        panzer[25].Xp=panzer[25].Xp+panzer[24].Xp+panzer[0].Xp;

        cout&lt;&lt;&quot;Willkommen beim XP Calculator made by Stevie04&amp;Panzer_mux!\n\n&quot;; // Des konnt ich mir nich verkneifen ;D
        cout &lt;&lt; &quot;Deutsche Panzer:\n&quot; 
             &lt;&lt; &quot;\n***Panzer***&quot; 
             &lt;&lt; endl;
        for (int i=0; i &lt; anzahl; i++){       // Damit alles angezeigt wird
          cout.fill('/');                     // Deklaration für füll zeichen
          cout &lt;&lt; setiosflags(ios::right)     // Rechtsbündige-Schrift
               &lt;&lt; setw(15) &lt;&lt; DeutscheP  [i]  //Das die Wörter bis 15 Zeichen mit dem Zeichen / aufgefüllt werden 
               &lt;&lt; resetiosflags(ios::right)
               &lt;&lt; flush;
          };
        cout &lt;&lt; &quot;\n***Artillerie***&quot; &lt;&lt; endl;

        for (int i=0; i &lt; 9; i++) {
          cout.fill('/');
          cout &lt;&lt; setiosflags(ios::right)
               &lt;&lt; setw(15) &lt;&lt; DeutscheA [i]
               &lt;&lt; resetiosflags(ios::right)
               &lt;&lt; flush;
          };

        cout &lt;&lt;&quot;\n***JagdPanzer***\n&quot; &lt;&lt; endl;  
        for (int i =0; i&lt;14;i++)  {
          cout.fill('/');
          cout &lt;&lt; setiosflags(ios::right)
               &lt;&lt; setw(15) &lt;&lt; DeutscheJP [i]
               &lt;&lt; resetiosflags(ios::right)
               &lt;&lt; flush;
          };

        cout&lt;&lt;&quot;\nBitte geben Sie den Namen Ihres Startpanzers aus der oberen Liste ein:&quot; &quot;\n&quot;&lt;&lt; flush;
        cin&gt;&gt; zielpanzer.s;

        for (int i=0;i&lt;LEN;i++)//startpanzer aussuchen
                if(strncmp(panzer[i].s,zielpanzer.s,20)==0)
                        {start=i; break;}
        cout&lt;&lt;&quot;Bitte geben Sie den Namen Ihres Zielpanzers aus der oberen Liste ein:&quot; &quot;\n&quot;;
        cin&gt;&gt; zielpanzer.s;
        for (int i=0;i&lt;LEN;i++)//startpanzer aussuchen
                if(strncmp(panzer[i].s,zielpanzer.s,20)==0)
                        {ziel=i;break;}
        panzer[3].Xp=panzer[start].Xp-panzer[ziel].Xp;
        cout&lt;&lt; &quot;Ergebnis:&quot; &lt;&lt; panzer[3].Xp*(-1) &lt;&lt; &quot;XP&quot; &quot;\n&quot;;
        cin.clear();
cin.ignore(cin.rdbuf()-&gt;in_avail());
cin.get(); 
}
</code></pre>
<p>Gemeint is das Char Array: DeutscheJP... probierts doch mal aus <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="🙂"
    /> (WIn 7 müsste probleme machen. wenn ja dann die header StdAfx.h einbinden!)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2006708</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2006708</guid><dc:creator><![CDATA[Prog_mux]]></dc:creator><pubDate>Fri, 14 Jan 2011 20:17:22 GMT</pubDate></item><item><title><![CDATA[Reply to cout gibt das char array nich aus! on Fri, 14 Jan 2011 20:22:45 GMT]]></title><description><![CDATA[<p>Du solltest darauf achten, dass deine Ausgabeschleifen nicht weiter laufen, als deine Arrays groß sind.</p>
<p>Allgemein könntest du davon profitieren, wenn du statt Arrays std::vector und statt char-Zeigern std::string verwendest.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2006714</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2006714</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Fri, 14 Jan 2011 20:22:45 GMT</pubDate></item><item><title><![CDATA[Reply to cout gibt das char array nich aus! on Fri, 14 Jan 2011 20:24:59 GMT]]></title><description><![CDATA[<p>hu!? Von denen hab ich noch nichts gehört <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> Bin noch neuling auf dem c++ gebiet!<br />
könntest du mir bitte noch die gesamte syntax für die funktionen posten? wäre nett!<br />
Mux</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2006716</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2006716</guid><dc:creator><![CDATA[Prog_mux]]></dc:creator><pubDate>Fri, 14 Jan 2011 20:24:59 GMT</pubDate></item><item><title><![CDATA[Reply to cout gibt das char array nich aus! on Fri, 14 Jan 2011 20:26:06 GMT]]></title><description><![CDATA[<p>Probier mal folgendes:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string.h&gt;
#include &lt;iomanip&gt;

using namespace std;

const int LEN = 30;
const int anzahl = 14;

int main()
{

char *DeutscheJP[9] = {&quot;PanzerJagerI\n&quot;,&quot;MarderII\n&quot;,
                      &quot;Hetzer\n&quot;,&quot;StugIII\n&quot;,
                      &quot;JgdPzIV\n&quot;,&quot;JagdPanther\n&quot;,
                      &quot;Ferdindand\n&quot;,&quot;JagdTiger\n&quot;};

char *DeutscheP [15] = {&quot;Leichttraktor\n&quot;,&quot;PzKpfwII\n&quot;,
                      &quot;PzKpfwIIIAusfA\n&quot;,
                      &quot;PanzerIII\n&quot;,                    
                      &quot;PanzerIV\n&quot;,&quot;3601H\n&quot;,
                      &quot;TigerI\n&quot;,&quot;TigerII\n&quot;,
                      &quot;4502AusfB\n&quot;,&quot;Maus\n&quot;,
                      &quot;PanzerIII/IV\n&quot;,&quot;3001P\n&quot;,
                      &quot;3002DB\n&quot;,&quot;Panther\n&quot;,
                      };

char *DeutscheA [5] =  {&quot;Bison\n&quot;,&quot;SturmpanzerII\n&quot;,
                       &quot;Grille\n&quot;,&quot;Hummel\n&quot;
                      };
class String {
  public:
  char *s;                 // Zeichenkette
  int Xp;
  String(void)  {s=new char [20];};
};

        String panzer[LEN];
        String zielpanzer;
        int start,ziel;
        panzer[0].s=&quot;Leichttraktor\0&quot;; panzer[0].Xp=0;
        panzer[1].s=&quot;PzKpfwII\0&quot;; panzer[1].Xp=175;
        panzer[2].s=&quot;PzKpfwIIIAusfA\0&quot;; panzer[2].Xp=1135;
        panzer[2].Xp=panzer[2].Xp+panzer[0].Xp+panzer[1].Xp;
        panzer[3].s=&quot;PanzerIII\0&quot;; panzer[3].Xp=4235;
        panzer[3].Xp=panzer[3].Xp+panzer[2].Xp+panzer[0].Xp;
        panzer[4].s=&quot;PanzerIV\0&quot;; panzer[4].Xp=15455;
        panzer[4].Xp=panzer[4].Xp+panzer[3].Xp+panzer[0].Xp;
        panzer[5].s=&quot;3601H\0&quot;; panzer[5].Xp=29955;
        panzer[5].Xp=panzer[5].Xp+panzer[4].Xp+panzer[0].Xp;
        panzer[6].s=&quot;TigerI\0&quot;; panzer[6].Xp=54065;
        panzer[6].Xp=panzer[6].Xp+panzer[5].Xp+panzer[0].Xp;
        panzer[7].s=&quot;TigerII\0&quot;; panzer[7].Xp=120495;
        panzer[7].Xp=panzer[7].Xp+panzer[6].Xp+panzer[0].Xp;
        panzer[8].s=&quot;4502AusfB\0&quot;; panzer[8].Xp=185750;
        panzer[8].Xp=panzer[8].Xp+panzer[7].Xp+panzer[0].Xp;
        panzer[9].s=&quot;Maus\0&quot;; panzer[9].Xp=279870;
        panzer[9].Xp=panzer[9].Xp+panzer[8].Xp+panzer[0].Xp;
        panzer[10].s=&quot;PanzerIII/IV\0&quot;; panzer[10].Xp=15455;
        panzer[10].Xp=panzer[10].Xp+panzer[3].Xp+panzer[0].Xp;
        panzer[11].s=&quot;3001P\0&quot;; panzer[11].Xp=29635;
        panzer[11].Xp=panzer[11].Xp+panzer[10].Xp+panzer[0].Xp;
        panzer[12].s=&quot;3002DB\0&quot;; panzer[12].Xp=41180;
        panzer[12].Xp=panzer[12].Xp+panzer[11].Xp+panzer[0].Xp;
        panzer[13].s=&quot;Panther\0&quot;; panzer[13].Xp=99135;
        panzer[13].Xp=panzer[13].Xp+panzer[12].Xp+panzer[0].Xp;
        panzer[14].s=&quot;Bison\0&quot;; panzer[14].Xp=155;
        panzer[15].s=&quot;SturmpanzerII\0&quot;; panzer[15].Xp=3605;
        panzer[15].Xp=panzer[15].Xp+panzer[14].Xp+panzer[0].Xp;
        panzer[16].s=&quot;Grille\0&quot;; panzer[16].Xp=14445;
        panzer[16].Xp=panzer[16].Xp+panzer[15].Xp+panzer[0].Xp;
        panzer[17].s=&quot;Hummel\0&quot;; panzer[17].Xp=48190;
        panzer[17].Xp=panzer[17].Xp+panzer[16].Xp+panzer[0].Xp;
        panzer[18].s=&quot;PanzerJagerI\0&quot;; panzer[18].Xp=185;
        panzer[19].s=&quot;MarderII\0&quot;; panzer[19].Xp=1425;
        panzer[19].Xp=panzer[19].Xp+panzer[18].Xp+panzer[0].Xp;
        panzer[20].s=&quot;Hetzer\0&quot;; panzer[20].Xp=5145;
        panzer[20].Xp=panzer[20].Xp+panzer[19].Xp+panzer[0].Xp;
        panzer[21].s=&quot;StugIII\0&quot;; panzer[21].Xp=12435;
        panzer[21].Xp=panzer[21].Xp+panzer[20].Xp+panzer[0].Xp;
        panzer[22].s=&quot;JgdPzIV\0&quot;; panzer[22].Xp=34785;
        panzer[22].Xp=panzer[22].Xp+panzer[21].Xp+panzer[0].Xp;
        panzer[23].s=&quot;JagdPanther\0&quot;; panzer[23].Xp=69240;
        panzer[23].Xp=panzer[23].Xp+panzer[22].Xp+panzer[0].Xp;
        panzer[24].s=&quot;Ferdindand\0&quot;; panzer[24].Xp=98630;
        panzer[24].Xp=panzer[24].Xp+panzer[23].Xp+panzer[0].Xp;
        panzer[25].s=&quot;JagdTiger\0&quot;; panzer[25].Xp=256040;
        panzer[25].Xp=panzer[25].Xp+panzer[24].Xp+panzer[0].Xp;

        cout&lt;&lt;&quot;Willkommen beim XP Calculator made by Stevie04&amp;Panzer_mux!\n\n&quot;; // Des konnt ich mir nich verkneifen ;D
        cout &lt;&lt; &quot;Deutsche Panzer:\n&quot;
             &lt;&lt; &quot;\n***Panzer***&quot;
             &lt;&lt; endl;
        for (int i=0; i &lt; anzahl; i++){       // Damit alles angezeigt wird
          cout.fill('/');                     // Deklaration für füll zeichen
          cout &lt;&lt; setiosflags(ios::right)     // Rechtsbündige-Schrift
               &lt;&lt; setw(15) &lt;&lt; DeutscheP  [i]  //Das die Wörter bis 15 Zeichen mit dem Zeichen / aufgefüllt werden
               &lt;&lt; resetiosflags(ios::right)
               &lt;&lt; flush;
          };
        cout &lt;&lt; &quot;\n***Artillerie***&quot; &lt;&lt; endl;

        for (int i=0; i &lt; 4; i++) {
          cout.fill('/');
          cout &lt;&lt; setiosflags(ios::right)
               &lt;&lt; setw(15) &lt;&lt; DeutscheA [i]
               &lt;&lt; resetiosflags(ios::right)
               &lt;&lt; flush;
          };

        cout &lt;&lt;&quot;\n***JagdPanzer***\n&quot; &lt;&lt; endl;  
        for (int i =0; i&lt;8;i++)  {
          cout.fill('/');
          cout &lt;&lt; setiosflags(ios::right)
               &lt;&lt; setw(15) &lt;&lt; DeutscheJP [i]
               &lt;&lt; resetiosflags(ios::right)
               &lt;&lt; flush;
          };

        cout&lt;&lt;&quot;\nBitte geben Sie den Namen Ihres Startpanzers aus der oberen Liste ein:&quot; &quot;\n&quot;&lt;&lt; flush;
        cin&gt;&gt; zielpanzer.s;

        for (int i=0;i&lt;LEN;i++)//startpanzer aussuchen
                if(strncmp(panzer[i].s,zielpanzer.s,20)==0)
                        {start=i; break;}
        cout&lt;&lt;&quot;Bitte geben Sie den Namen Ihres Zielpanzers aus der oberen Liste ein:&quot; &quot;\n&quot;;
        cin&gt;&gt; zielpanzer.s;
        for (int i=0;i&lt;LEN;i++)//startpanzer aussuchen
                if(strncmp(panzer[i].s,zielpanzer.s,20)==0)
                        {ziel=i;break;}
        panzer[3].Xp=panzer[start].Xp-panzer[ziel].Xp;
        cout&lt;&lt; &quot;Ergebnis:&quot; &lt;&lt; panzer[3].Xp*(-1) &lt;&lt; &quot;XP&quot; &quot;\n&quot;;
        cin.clear();
cin.ignore(cin.rdbuf()-&gt;in_avail());
cin.get();
}
</code></pre>
<p>Ich habe die Laufweite der Schleifen geändert. Du hast wohl über die Größe des Arrays hinaus gelesen.</p>
<p>Zu deinem Code: Der ist nicht nur unübersichtlich, der ist einfach nur Mist, fehleranfällig und auch fehlerhaft. Speicherreservierung ohne Freigabe...</p>
<p>Hier mal der Anfang eines anderen Ansatzes:</p>
<pre><code class="language-cpp">#include &lt;vector&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;

struct Fahrzeug
{
	std::string name;
	int xp;

	Fahrzeug(std::string n, int x) 
		: name(n), xp(x)
	{
	}
};

typedef std::vector&lt;Fahrzeug&gt; Fahrzeuge;

void Ausgabe(const Fahrzeuge&amp; vec);

int main()
{
	Fahrzeuge DeutschePanzer;
	Fahrzeuge JagdPanzer;
	Fahrzeuge Artillerien;

	// Panzer hinzufügen
	DeutschePanzer.push_back(Fahrzeug(&quot;Deutscher Panzer&quot;, 10));
	JagdPanzer.push_back(Fahrzeug(&quot;Jagdpanzer&quot;, 50));
	Artillerien.push_back(Fahrzeug(&quot;Artillerie&quot;, 100));

	// Ausgabe
	std::cout &lt;&lt; &quot;--- Deutsche Panzer ---&quot; &lt;&lt; std::endl;
	Ausgabe(DeutschePanzer);

	std::cout &lt;&lt; &quot;\n--- JagdPanzer ---&quot; &lt;&lt; std::endl;
	Ausgabe(JagdPanzer);

	std::cout &lt;&lt; &quot;\n--- Artillerien ---&quot; &lt;&lt; std::endl;
	Ausgabe(Artillerien);

	return 0;
}

void Ausgabe(const Fahrzeuge&amp; vec)
{
	for (Fahrzeuge::const_iterator it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout &lt;&lt; it-&gt;name &lt;&lt; &quot;, &quot; &lt;&lt; it-&gt;xp &lt;&lt; &quot; XP&quot; &lt;&lt; std::endl;
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2006718</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2006718</guid><dc:creator><![CDATA[köklökl]]></dc:creator><pubDate>Fri, 14 Jan 2011 20:26:06 GMT</pubDate></item><item><title><![CDATA[Reply to cout gibt das char array nich aus! on Fri, 14 Jan 2011 20:29:53 GMT]]></title><description><![CDATA[<p>haha <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=";D"
      alt="😉"
    /> der code is nich von mir sondern von stevie04^^ ich bin nur fürs äußerliche und verbesserungen zuständig <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="🙂"
    /> wir sind beide noch neulinge! Aber Danke für eure beiden antworten und es funktioniert jetzt! Danke nochmal<br />
Mux</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2006721</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2006721</guid><dc:creator><![CDATA[Prog_mux]]></dc:creator><pubDate>Fri, 14 Jan 2011 20:29:53 GMT</pubDate></item><item><title><![CDATA[Reply to cout gibt das char array nich aus! on Fri, 14 Jan 2011 21:00:54 GMT]]></title><description><![CDATA[<p>string...vector...</p>
<p>Prog_mux schrieb:</p>
<blockquote>
<p>hu!? Von denen hab ich noch nichts gehört <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> Bin noch neuling auf dem c++ gebiet!</p>
</blockquote>
<p>Du hast anscheinend einen Lehrer gefunden, der dir wohl auch erst Einradfahren beibringen würde, bevor er erwähnt, dass es auch Zweiräder mit Stützrädern gibt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2006728</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2006728</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 14 Jan 2011 21:00:54 GMT</pubDate></item><item><title><![CDATA[Reply to cout gibt das char array nich aus! on Fri, 14 Jan 2011 21:06:16 GMT]]></title><description><![CDATA[<p>ich bin mein lehrer <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=";D"
      alt="😉"
    /> ich hab erstmal nur ein buch mit grundlagen durchgelesen und bin grad halb mit OOP buch durch</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2006734</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2006734</guid><dc:creator><![CDATA[Prog_mux]]></dc:creator><pubDate>Fri, 14 Jan 2011 21:06:16 GMT</pubDate></item><item><title><![CDATA[Reply to cout gibt das char array nich aus! on Fri, 14 Jan 2011 21:20:06 GMT]]></title><description><![CDATA[<p>Prog_mux schrieb:</p>
<blockquote>
<p>ich bin mein lehrer <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=";D"
      alt="😉"
    /> ich hab erstmal nur ein buch mit grundlagen durchgelesen</p>
</blockquote>
<p>Dann war das vermutlich ein schlechtes Buch. Denn (char-)Arrays sind zwar für C Grundlagen, aber für C++ sind das exotische Randthemen. vector und string sind stattdessen die Grundlagen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2006737</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2006737</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 14 Jan 2011 21:20:06 GMT</pubDate></item><item><title><![CDATA[Reply to cout gibt das char array nich aus! on Sat, 15 Jan 2011 09:00:01 GMT]]></title><description><![CDATA[<p>grundsätzlich stand das da auch nich drin, kam eher noch aus meinem C-Wissen! Das buch hatte wirklich nur die absoluten grundlagen <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="🙂"
    /> im oop buch wirds noch kommen denk ich!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2006800</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2006800</guid><dc:creator><![CDATA[Prog_mux]]></dc:creator><pubDate>Sat, 15 Jan 2011 09:00:01 GMT</pubDate></item></channel></rss>