<?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[Problem mit schleifen Ausgabe]]></title><description><![CDATA[<p>Hi,</p>
<p>ich bin gerade dabei ein Program zu schreiben welches eine VTK schreibt. Es ist so gemacht das der User alle selber eingibt (nur mit einschränkungen auf die eingabe (bei zahlen nur zahlen usw.).</p>
<p>Ich kopier hier mal eine Beispiel Datei und makier stellen und schreib was dazu und danach komm ich dann zum Problem:</p>
<p># vtk DataFile Version 2.0<br />
Cube example<br />
ASCII<br />
DATASET POLYDATA<br />
POINTS 8 float &lt;-- die 8 ist ausschlaggebend für die weiteren eingaben<br />
0.0 0.0 0.0 denn durch diese eingabe wird ein Array erzeugt was der<br />
1.0 0.0 0.0 eingabe X 3 entspricht (liegt an dem Dateiformat)<br />
1.0 1.0 0.0<br />
0.0 1.0 0.0<br />
0.0 0.0 1.0<br />
1.0 0.0 1.0<br />
1.0 1.0 1.0<br />
0.0 1.0 1.0<br />
POLYGONS 6 30<br />
4 0 1 2 3<br />
4 4 5 6 7<br />
4 0 1 5 4<br />
4 2 3 7 6<br />
4 0 4 7 3<br />
4 1 2 6 5</p>
<p>so und das Problem ist jetzt das ich halt das Array erzeugen lasse und dannach eine Aufvorderung zur Eingabe in diesem Fall der 24 werte gebe. Das geht soweit und er speichert sie auch im array.</p>
<p>Aber dann wenn ich die Werte dann in ein File schreiben will dann kommt sowas bei raus:<br />
(ist aber nur bis zum Problem)</p>
<p># vtk DataFile Version 2.0<br />
Test<br />
ASCII<br />
DATASET POLYDATA<br />
POINTS 8 float</p>
<p>0 0 0<br />
1 0 0<br />
1 1 0<br />
0 1 0<br />
0 0 1<br />
1 0 1<br />
1 1 1<br />
0 48 1 &lt;---- die 48 kann ich mir ned erklären<br />
7143541 2293536 2293088 &lt;---- und das auch nicht</p>
<p>ok da das ganze geschreibe ned viel nützt jetzt der code:</p>
<pre><code class="language-cpp">#include &lt;fstream&gt;
#include &lt;iostream&gt; 
#include &lt;string&gt;

using namespace std;

//Strings
string var2 = &quot; &quot;;
string var6 = &quot;\n&quot;;
string vtkV = &quot;# vtk DataFile Version&quot;;
string null = &quot;.0&quot;;
string ASCII = &quot;&quot;;
string data = &quot;DATASET&quot;;
string Name;
string dataein;
string polydata;
string part;
string pfad;
string PName;
string VTK = &quot;.vtk&quot;;

int version;

int main ( )

{
//Variablen  
int i;    
int array [i];         
int version;
int panzahl;
int poly1;
int poly2;
int dataei;
int polyZ;
int BINARY;

       //Name der Datei unter dem sie dann abgespeichert wird     
       cout &lt;&lt; &quot; \n Bitte Name der Datei eingeben \n&quot;;
       cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; Name;
       //Pfad angeben wo datei dann gespeichert wird
       cout &lt;&lt; &quot; \n Bitte Pfad eingeben \n&quot;;
       cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; pfad;
       //Wahl der VTK Version 1, 2 oder 3.
       cout &lt;&lt; &quot; \n Bitte VTK Versionsnummer eingeben \n&quot;;
       cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; version;
       //Name in der Datei z.B. kurze beschreibung (ohne Leerzeichen)!
       cout &lt;&lt; &quot; \n Bitte Projekt Namen der Datei eingeben \n&quot;;
       cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; PName;

       // Wahl zwischen ASCII und BINARY
       cout &lt;&lt; &quot; \n Bitte zwischen ASCII | BINARY wählen \n&quot;;
       cout &lt;&lt; &quot; \n 1. ASCII &quot;;
       cout &lt;&lt; &quot; \n 2. BINARY &quot;;
       cout &lt;&lt; &quot;\n\n &quot;; cin  &gt;&gt; BINARY;
       if (BINARY == 1)
       ASCII = (&quot;ASCII&quot;);
       else if (BINARY == 2)
       ASCII = (&quot;BINARY&quot;);
       else if (BINARY &gt; 2)
       return 0;

       //DATASET type wählen

       cout &lt;&lt; &quot; \n Bitte Datei Art wählen &quot;;
       cout &lt;&lt; &quot; \n 1. STRUCTURED_POINTS &quot;;
       cout &lt;&lt; &quot; \n 2. STRUCTURED_GRID &quot;;
       cout &lt;&lt; &quot; \n 3. UNSTRUCTURED_GRID &quot;;
       cout &lt;&lt; &quot; \n 4. POLYDATA &quot;;
       cout &lt;&lt; &quot; \n 5. RECTILINEAR_GRID &quot;;
       cout &lt;&lt; &quot; \n 6. FIELD &quot;;
       cout &lt;&lt; &quot;\n\n &quot;; cin  &gt;&gt; dataei;

/*Dataset attributes. The number of data
items n of each type must match the number
of points or cells in the dataset. (If type is
FIELD, point and cell data should be omitted.
*/
     if (dataei == 1)
     dataein = (&quot;STRUCTURED_POINTS&quot;);
     else if (dataei == 2)
     dataein = (&quot;STRUCTURED_GRID&quot;);
     else if (dataei == 3)
     dataein = (&quot;UNSTRUCTURED_GRID&quot;);
     else if (dataei == 4)
     dataein = (&quot;POLYDATA&quot;);
     else if (dataei == 5)
     dataein = (&quot;RECTILINEAR_GRID&quot;);
     else if (dataei == 6)
     dataein = (&quot;FIELD&quot;);
     else if (dataei &gt; 6)
     return 0;

if (dataei == 4)

       cout &lt;&lt; &quot; \n Bitte POLYDATA wählen &quot;;
       cout &lt;&lt; &quot; \n 1. POINTS &quot;;
       cout &lt;&lt; &quot; \n 2. VERTICES &quot;;
       cout &lt;&lt; &quot; \n 3. LINES &quot;;
       cout &lt;&lt; &quot; \n 4. POLYGONS &quot;;
       cout &lt;&lt; &quot; \n 5. TRIANGLE_STRIPS &quot;;
       cout &lt;&lt; &quot;\n\n &quot;; cin &gt;&gt; polyZ;

if (polyZ == 1)
 polydata = (&quot;POINTS&quot;);
else if (polyZ == 2)
 polydata = (&quot;VERTICES&quot;);
else if (polyZ == 3)
 polydata = (&quot;LINES&quot;);
else if (polyZ == 4)
 polydata = (&quot;POLYGONS&quot;);
else if (polyZ == 5)
 polydata = (&quot;TRIANGLE_STRIPS&quot;);
else if (polyZ &gt; 5)
return 0;

      cout &lt;&lt; &quot; \n Bitte Anzahl der Points eingeben \n&quot;;
      cout &lt;&lt; &quot; \n &quot;; cin  &gt;&gt; panzahl;
      cout &lt;&lt; &quot; \n Bitte Pointart eingeben \n&quot;;
      cout &lt;&lt; &quot;\n &quot;; cin &gt;&gt; part;

      int x;
      x = panzahl * 3;
      cout &lt;&lt; &quot;\nJetzt bitte &quot; &lt;&lt; x &lt;&lt; &quot; &quot; &lt;&lt; polydata &lt;&lt; &quot; eingeben&quot;;

             for (i = 1; i &lt;= x ; i++)
 {

  cout &lt;&lt; &quot;\n&quot;;
  cin &gt;&gt; array[i];

 } 

    string pfad2 = pfad + Name + VTK;  
    pfad2.c_str(); //steht dann für char

 {

  ofstream myFile;
  myFile.open (pfad2.c_str());

if (myFile)
{ 

     myFile &lt;&lt; vtkV &lt;&lt; var2 &lt;&lt; version &lt;&lt; null &lt;&lt;  var6 &lt;&lt; PName &lt;&lt; var6 &lt;&lt; ASCII &lt;&lt; var6 &lt;&lt; data &lt;&lt; var2 &lt;&lt; dataein &lt;&lt; var6 &lt;&lt; polydata &lt;&lt; var2 &lt;&lt; panzahl &lt;&lt; var2 &lt;&lt; part &lt;&lt; var6 &lt;&lt;    endl;

for (i=0; i&lt;= panzahl; i++)
 {
          for (int j = 1; j&lt;=3; j++)
          {
             myFile &lt;&lt; array[i*3+j] &lt;&lt; var2;
              }
              myFile &lt;&lt; endl;
          }

     myFile.close();
               for (i = 1; i &lt;= x ; i++)
 {

  cout &lt;&lt; i;

 } 

}    
     system(&quot;pause&quot;);

  }

}
</code></pre>
<p>hoffe mal ich habs jetzt richtig gemacht<br />
naja und der code ist ned sonderlich gut und so und ich bin offen für verbesserungen und ist noch total unvollständig</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/188010/problem-mit-schleifen-ausgabe</link><generator>RSS for Node</generator><lastBuildDate>Fri, 25 Sep 2026 01:09:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/188010.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 26 Jul 2007 09:29:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Thu, 26 Jul 2007 09:39:12 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich bin gerade dabei ein Program zu schreiben welches eine VTK schreibt. Es ist so gemacht das der User alle selber eingibt (nur mit einschränkungen auf die eingabe (bei zahlen nur zahlen usw.).</p>
<p>Ich kopier hier mal eine Beispiel Datei und makier stellen und schreib was dazu und danach komm ich dann zum Problem:</p>
<p># vtk DataFile Version 2.0<br />
Cube example<br />
ASCII<br />
DATASET POLYDATA<br />
POINTS 8 float &lt;-- die 8 ist ausschlaggebend für die weiteren eingaben<br />
0.0 0.0 0.0 denn durch diese eingabe wird ein Array erzeugt was der<br />
1.0 0.0 0.0 eingabe X 3 entspricht (liegt an dem Dateiformat)<br />
1.0 1.0 0.0<br />
0.0 1.0 0.0<br />
0.0 0.0 1.0<br />
1.0 0.0 1.0<br />
1.0 1.0 1.0<br />
0.0 1.0 1.0<br />
POLYGONS 6 30<br />
4 0 1 2 3<br />
4 4 5 6 7<br />
4 0 1 5 4<br />
4 2 3 7 6<br />
4 0 4 7 3<br />
4 1 2 6 5</p>
<p>so und das Problem ist jetzt das ich halt das Array erzeugen lasse und dannach eine Aufvorderung zur Eingabe in diesem Fall der 24 werte gebe. Das geht soweit und er speichert sie auch im array.</p>
<p>Aber dann wenn ich die Werte dann in ein File schreiben will dann kommt sowas bei raus:<br />
(ist aber nur bis zum Problem)</p>
<p># vtk DataFile Version 2.0<br />
Test<br />
ASCII<br />
DATASET POLYDATA<br />
POINTS 8 float</p>
<p>0 0 0<br />
1 0 0<br />
1 1 0<br />
0 1 0<br />
0 0 1<br />
1 0 1<br />
1 1 1<br />
0 48 1 &lt;---- die 48 kann ich mir ned erklären<br />
7143541 2293536 2293088 &lt;---- und das auch nicht</p>
<p>ok da das ganze geschreibe ned viel nützt jetzt der code:</p>
<pre><code class="language-cpp">#include &lt;fstream&gt;
#include &lt;iostream&gt; 
#include &lt;string&gt;

using namespace std;

//Strings
string var2 = &quot; &quot;;
string var6 = &quot;\n&quot;;
string vtkV = &quot;# vtk DataFile Version&quot;;
string null = &quot;.0&quot;;
string ASCII = &quot;&quot;;
string data = &quot;DATASET&quot;;
string Name;
string dataein;
string polydata;
string part;
string pfad;
string PName;
string VTK = &quot;.vtk&quot;;

int version;

int main ( )

{
//Variablen  
int i;    
int array [i];         
int version;
int panzahl;
int poly1;
int poly2;
int dataei;
int polyZ;
int BINARY;

       //Name der Datei unter dem sie dann abgespeichert wird     
       cout &lt;&lt; &quot; \n Bitte Name der Datei eingeben \n&quot;;
       cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; Name;
       //Pfad angeben wo datei dann gespeichert wird
       cout &lt;&lt; &quot; \n Bitte Pfad eingeben \n&quot;;
       cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; pfad;
       //Wahl der VTK Version 1, 2 oder 3.
       cout &lt;&lt; &quot; \n Bitte VTK Versionsnummer eingeben \n&quot;;
       cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; version;
       //Name in der Datei z.B. kurze beschreibung (ohne Leerzeichen)!
       cout &lt;&lt; &quot; \n Bitte Projekt Namen der Datei eingeben \n&quot;;
       cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; PName;

       // Wahl zwischen ASCII und BINARY
       cout &lt;&lt; &quot; \n Bitte zwischen ASCII | BINARY wählen \n&quot;;
       cout &lt;&lt; &quot; \n 1. ASCII &quot;;
       cout &lt;&lt; &quot; \n 2. BINARY &quot;;
       cout &lt;&lt; &quot;\n\n &quot;; cin  &gt;&gt; BINARY;
       if (BINARY == 1)
       ASCII = (&quot;ASCII&quot;);
       else if (BINARY == 2)
       ASCII = (&quot;BINARY&quot;);
       else if (BINARY &gt; 2)
       return 0;

       //DATASET type wählen

       cout &lt;&lt; &quot; \n Bitte Datei Art wählen &quot;;
       cout &lt;&lt; &quot; \n 1. STRUCTURED_POINTS &quot;;
       cout &lt;&lt; &quot; \n 2. STRUCTURED_GRID &quot;;
       cout &lt;&lt; &quot; \n 3. UNSTRUCTURED_GRID &quot;;
       cout &lt;&lt; &quot; \n 4. POLYDATA &quot;;
       cout &lt;&lt; &quot; \n 5. RECTILINEAR_GRID &quot;;
       cout &lt;&lt; &quot; \n 6. FIELD &quot;;
       cout &lt;&lt; &quot;\n\n &quot;; cin  &gt;&gt; dataei;

/*Dataset attributes. The number of data
items n of each type must match the number
of points or cells in the dataset. (If type is
FIELD, point and cell data should be omitted.
*/
     if (dataei == 1)
     dataein = (&quot;STRUCTURED_POINTS&quot;);
     else if (dataei == 2)
     dataein = (&quot;STRUCTURED_GRID&quot;);
     else if (dataei == 3)
     dataein = (&quot;UNSTRUCTURED_GRID&quot;);
     else if (dataei == 4)
     dataein = (&quot;POLYDATA&quot;);
     else if (dataei == 5)
     dataein = (&quot;RECTILINEAR_GRID&quot;);
     else if (dataei == 6)
     dataein = (&quot;FIELD&quot;);
     else if (dataei &gt; 6)
     return 0;

if (dataei == 4)

       cout &lt;&lt; &quot; \n Bitte POLYDATA wählen &quot;;
       cout &lt;&lt; &quot; \n 1. POINTS &quot;;
       cout &lt;&lt; &quot; \n 2. VERTICES &quot;;
       cout &lt;&lt; &quot; \n 3. LINES &quot;;
       cout &lt;&lt; &quot; \n 4. POLYGONS &quot;;
       cout &lt;&lt; &quot; \n 5. TRIANGLE_STRIPS &quot;;
       cout &lt;&lt; &quot;\n\n &quot;; cin &gt;&gt; polyZ;

if (polyZ == 1)
 polydata = (&quot;POINTS&quot;);
else if (polyZ == 2)
 polydata = (&quot;VERTICES&quot;);
else if (polyZ == 3)
 polydata = (&quot;LINES&quot;);
else if (polyZ == 4)
 polydata = (&quot;POLYGONS&quot;);
else if (polyZ == 5)
 polydata = (&quot;TRIANGLE_STRIPS&quot;);
else if (polyZ &gt; 5)
return 0;

      cout &lt;&lt; &quot; \n Bitte Anzahl der Points eingeben \n&quot;;
      cout &lt;&lt; &quot; \n &quot;; cin  &gt;&gt; panzahl;
      cout &lt;&lt; &quot; \n Bitte Pointart eingeben \n&quot;;
      cout &lt;&lt; &quot;\n &quot;; cin &gt;&gt; part;

      int x;
      x = panzahl * 3;
      cout &lt;&lt; &quot;\nJetzt bitte &quot; &lt;&lt; x &lt;&lt; &quot; &quot; &lt;&lt; polydata &lt;&lt; &quot; eingeben&quot;;

             for (i = 1; i &lt;= x ; i++)
 {

  cout &lt;&lt; &quot;\n&quot;;
  cin &gt;&gt; array[i];

 } 

    string pfad2 = pfad + Name + VTK;  
    pfad2.c_str(); //steht dann für char

 {

  ofstream myFile;
  myFile.open (pfad2.c_str());

if (myFile)
{ 

     myFile &lt;&lt; vtkV &lt;&lt; var2 &lt;&lt; version &lt;&lt; null &lt;&lt;  var6 &lt;&lt; PName &lt;&lt; var6 &lt;&lt; ASCII &lt;&lt; var6 &lt;&lt; data &lt;&lt; var2 &lt;&lt; dataein &lt;&lt; var6 &lt;&lt; polydata &lt;&lt; var2 &lt;&lt; panzahl &lt;&lt; var2 &lt;&lt; part &lt;&lt; var6 &lt;&lt;    endl;

for (i=0; i&lt;= panzahl; i++)
 {
          for (int j = 1; j&lt;=3; j++)
          {
             myFile &lt;&lt; array[i*3+j] &lt;&lt; var2;
              }
              myFile &lt;&lt; endl;
          }

     myFile.close();
               for (i = 1; i &lt;= x ; i++)
 {

  cout &lt;&lt; i;

 } 

}    
     system(&quot;pause&quot;);

  }

}
</code></pre>
<p>hoffe mal ich habs jetzt richtig gemacht<br />
naja und der code ist ned sonderlich gut und so und ich bin offen für verbesserungen und ist noch total unvollständig</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1332829</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1332829</guid><dc:creator><![CDATA[GT]]></dc:creator><pubDate>Thu, 26 Jul 2007 09:39:12 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Thu, 26 Jul 2007 09:48:42 GMT]]></title><description><![CDATA[<p>Erstmal solltest du deinen Variablen vernünftige Bezeichnungen geben (wenn es denn überhaupt notwendig ist, das Leerzeichen in einem String aufzubewahren, dann nenn' diesen wenigstens 'space' und nicht 'var2').</p>
<p>Zweitens kannst du die ganzen if-else-Kaskaden viel kompakter über Array lösen.</p>
<p>Und drittens: Woher die 48 kommt, bin ich auf Anhieb auch überfragt. Die drei Riesenzahlen am Ende kommen auf jeden Fall von einer Index-Überschreitung (mach aus dem i&lt;=panzahl ein i&lt;panzahl).</p>
<p>PS: Und VLAs gibt es in C++ nicht - und selbst in C99 dürfte eine Anweisung <code>int i;int array[i];</code> nicht funktionieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1332848</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1332848</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 26 Jul 2007 09:48:42 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Thu, 26 Jul 2007 10:03:43 GMT]]></title><description><![CDATA[<p>Hey danke des ändern auf</p>
<p>for (i=0; i&lt; panzahl; i++)</p>
<p>hat schon geholfen</p>
<p>nur die 48 ist noch da</p>
<p>also was merkwürdig ist aber vieleicht aufschluss aufs problem gibt ist<br />
(hab grad getestet)</p>
<p>das bei 1 als eingabe keine 48 da ist, aber wenn ich wieder 8 nehm wie im Beispiel File dann kommt die 48 aber immer auf der vorletzten stelle also in diesem fall die 23te</p>
<p>naja</p>
<p>mal sehn</p>
<p>danke schonmal</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1332863</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1332863</guid><dc:creator><![CDATA[GT]]></dc:creator><pubDate>Thu, 26 Jul 2007 10:03:43 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Thu, 26 Jul 2007 10:07:40 GMT]]></title><description><![CDATA[<p>Kannst du eventuell deine seltsame VLA-Konstruktion (int array[i]) durch etwas vernünftiges ersetzen - da wundert es mich sowieso, wie das durch den Compiler gekommen ist (und dann ohne ernsthafte Abstürze funktioniert hat).</p>
<p>Und außerdem solltest du daran denken, daß C++ Arrays bei 0 beginnen <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/1332870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1332870</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 26 Jul 2007 10:07:40 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Thu, 26 Jul 2007 10:12:52 GMT]]></title><description><![CDATA[<p>ja also abstürze gabs noch keine</p>
<p>und ja könnte ich schon tun nur durch was? vorschlag dann setz ich das mal um.</p>
<p>Aber jetzt hab ich nen anders problem, wo wir schon bei abstürzen sind wenn ich einen wert über 8 eingeb dann stürzt das program ab sobald ich die letzte zahl eingegeben hab.</p>
<p>ja stimmt beginnen ja mit 0</p>
<p>hmmm</p>
<p>danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1332875</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1332875</guid><dc:creator><![CDATA[GT]]></dc:creator><pubDate>Thu, 26 Jul 2007 10:12:52 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Thu, 26 Jul 2007 10:59:04 GMT]]></title><description><![CDATA[<p>Soll ich es etwas größer schreiben? Dein Versuch eines VLA ist unsinnig (und wie du gesehen hast, ist es nur eine Frage der Zeit, bis es kracht).</p>
<p>In C++ verwendet man für solche Aufgaben vector&lt;&gt;en:</p>
<pre><code class="language-cpp">vector&lt;int&gt;array;
...
x = panzahl * 3;
cout &lt;&lt; &quot;\nJetzt bitte &quot; &lt;&lt; x &lt;&lt; &quot; &quot; &lt;&lt; polydata &lt;&lt; &quot; eingeben&quot;;
array.resize(x);
for (i = 0; i &lt; x ; i++)
{
  cout &lt;&lt; &quot;\n&quot;;
  cin &gt;&gt; array[i];
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1332905</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1332905</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 26 Jul 2007 10:59:04 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Thu, 26 Jul 2007 11:10:13 GMT]]></title><description><![CDATA[<p>aha</p>
<p>ok ich werds mal so probiern und das ganze Programm mal überarbeiten.</p>
<p>Hast schon recht</p>
<p>ja auf jedenfall ists ja so versuchs programm und auf jedenfall hat es viele verbesserungen nötig.</p>
<p>mal sehn wie ich jetzt weiter machen werde aber dein tipp werde ich jetzt berücksichtigen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1332919</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1332919</guid><dc:creator><![CDATA[GT]]></dc:creator><pubDate>Thu, 26 Jul 2007 11:10:13 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Thu, 26 Jul 2007 11:36:04 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>spontan fällt mir bei den &quot;if-else-if&quot;'s auf, dass sie seeeeehr fehleranfällig sind. Ist zwar eigentlich nur eine Frage der Formatierung, aber mehr als nur &quot;Geschmackssache&quot;.</p>
<p>Mal Fragen:<br />
1.) Weißt Du, dass nur EINE Anweisung hinter einem if (&quot;if(<em>bedingung</em>) <em>anweisung</em>;&quot;) dem if zugeordnet wird ?<br />
Also:</p>
<pre><code class="language-cpp">if (BINARY == 1)
  ASCII = (&quot;ASCII&quot;); // wird nur ausgeführt, wenn BINARY==1 ist
  something = 2;  // wird IMMER ausgeführt
  else            // Compiler-error: &quot;misplaced else&quot;
  something = 3;
</code></pre>
<p>Das hast Du zwar (noch) nicht falsch gemacht, aber Dein Code ist seeeeehr anfällig für diesen Fehler.</p>
<p>2.) kennst Du die switch-case-Konstruktion ?<br />
Also:</p>
<pre><code class="language-cpp">switch(BINARY) {
   case 1:  
      ASCII = (&quot;ASCII&quot;);
      break;
   case 2:
      ASCII = (&quot;BINARY&quot;);
      break;
   default: // sonst
      return 0;
   }
</code></pre>
<p>Beides könnte Dir weiterhelfen.</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1332942</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1332942</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Thu, 26 Jul 2007 11:36:04 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Thu, 26 Jul 2007 11:40:58 GMT]]></title><description><![CDATA[<p>Und bei dem Aussehen der if-Kaskaden könnte man das auch noch kompakter lösen (aber das fällt schon unter &quot;fortgeschrittene Programmiertechniken&quot;):</p>
<pre><code class="language-cpp">//aus:
if (polyZ == 1) 
 polydata = (&quot;POINTS&quot;); 
else if (polyZ == 2) 
 polydata = (&quot;VERTICES&quot;); 
else if (polyZ == 3) 
 polydata = (&quot;LINES&quot;); 
else if (polyZ == 4) 
 polydata = (&quot;POLYGONS&quot;); 
else if (polyZ == 5) 
 polydata = (&quot;TRIANGLE_STRIPS&quot;); 
else if (polyZ &gt; 5) 
return 0;

//wird:
string polytypes[]={&quot;POINTS&quot;,&quot;VERTICES&quot;,&quot;LINES&quot;,&quot;TRIANGLE_STRIPS&quot;};
if(polyZ&lt;=5)
  polydata = polytypes[polyZ-1];
else return 0;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1332948</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1332948</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 26 Jul 2007 11:40:58 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Thu, 26 Jul 2007 11:41:23 GMT]]></title><description><![CDATA[<p>ja ich kenn die switch-case-Konstruktion</p>
<p>und da ich den code komplett überarbeiten werde werde ich das mit einbinden</p>
<p>und auch dir danke für die hinweise und hilfe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1332949</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1332949</guid><dc:creator><![CDATA[GT]]></dc:creator><pubDate>Thu, 26 Jul 2007 11:41:23 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Thu, 26 Jul 2007 13:44:56 GMT]]></title><description><![CDATA[<p>hab jetzt bisserl rumprobiert und mach grad des mit den vektoren</p>
<p>das klapt auch gut Danke nochmal guter tipp auch das andere</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;
#include &lt;fstream&gt;

#include &lt;string&gt;

#include&lt;vector&gt;

using namespace std;
string space = &quot; &quot;;
int main()

{
    vector&lt;int&gt; Array;

cout &lt;&lt; &quot;Bitte Werte eingeben\n&quot;;

int ArrayWert;

do{

cout &lt;&lt; &quot;Wert (999 = Ende der Eingabe):&quot;;

cin &gt;&gt; ArrayWert;

if(ArrayWert != 999)

Array.push_back(ArrayWert);

} while(ArrayWert != 999);

cout &lt;&lt; &quot;Es wurden die folgenden Werte eingegeben:\n&quot;;

for(int i = 0; i &lt; Array.size(); i++)

cout &lt;&lt; i &lt;&lt; &quot;. Wert : &quot;

&lt;&lt; Array[i] &lt;&lt; endl;

int PointAnzahl;
ofstream myFile;
 myFile.open (&quot;C:/Test.vtk&quot;);

if (myFile)
{ 

for (int l=0; l&lt; PointAnzahl; l++)
 {
          for (int j = 0; j&lt;=3; j++)
          {
             myFile &lt;&lt; Array[l*3+j] &lt;&lt; space;
              }
              myFile &lt;&lt; endl;
          }

     myFile.close();

system(&quot;pause&quot;);
}
}
</code></pre>
<p>würd mich über genau so gute hilfe wie vorher freun</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1333056</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1333056</guid><dc:creator><![CDATA[GT]]></dc:creator><pubDate>Thu, 26 Jul 2007 13:44:56 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Thu, 26 Jul 2007 13:34:42 GMT]]></title><description><![CDATA[<p>Du hast vergessen, PointAnzahl zu initialisieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1333063</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1333063</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 26 Jul 2007 13:34:42 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Thu, 26 Jul 2007 13:41:41 GMT]]></title><description><![CDATA[<p>hupps stimmt danke</p>
<p>mai mai bin ich doof</p>
<p>aber find ich voll gut das forum großes lob</p>
<p>Und dir CStoll danke für die ganze hilfe <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="🙂"
    /></p>
<p>PS:</p>
<p>War auch der Falsche Code ich poste ihn oben nochmal</p>
<p>Kommt davon wenn man im compiler und in Notepad rumarbeitet und dann des falsche kopiert</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1333072</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1333072</guid><dc:creator><![CDATA[GT]]></dc:creator><pubDate>Thu, 26 Jul 2007 13:41:41 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Fri, 27 Jul 2007 07:04:33 GMT]]></title><description><![CDATA[<p>also hier mal ne abgeänderte version (nicht fertig nicht komplett und so)</p>
<pre><code class="language-cpp">#include &lt;fstream&gt;
#include &lt;iostream&gt; 
#include &lt;string&gt;
#include&lt;vector&gt;

using namespace std;

//Strings
string space = &quot; &quot;;
string enter = &quot;\n&quot;;
string vtkversion = &quot;# vtk DataFile Version&quot;;
string null = &quot;.0&quot;;
string ASCIIBINARY = &quot;&quot;;
string dataset = &quot;DATASET&quot;;
string EingabeName;
string Dataseteingabe;
string polydata;
string Pointart;
string pfad;
string ProjektName;
string VTK = &quot;.vtk&quot;;

int version;

int main ( )

{
//Variablen  
int i;    
int array [i];         
int version;
int PointAnzahl;
int Dateieingabe;
int PolydataZahl;
int ASCIIBINARYzahl;

       //Name der Datei unter dem sie dann abgespeichert wird     
       cout &lt;&lt; &quot; \n Bitte Name der Datei eingeben \n&quot;;
       cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; EingabeName;
       //Pfad angeben wo datei dann gespeichert wird
       cout &lt;&lt; &quot; \n Bitte Pfad eingeben \n&quot;;
       cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; pfad;
       //Wahl der VTK Version 1, 2 oder 3.
       cout &lt;&lt; &quot; \n Bitte VTK Versionsnummer eingeben \n&quot;;
       cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; version;
       //Name in der Datei z.B. kurze beschreibung (ohne Leerzeichen)!
       cout &lt;&lt; &quot; \n Bitte Projekt Namen der Datei eingeben \n&quot;;
       cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; ProjektName;

       // Wahl zwischen ASCII und BINARY
       cout &lt;&lt; &quot; \n Bitte zwischen ASCII | BINARY wählen \n&quot;;
       cout &lt;&lt; &quot; \n 1. ASCII &quot;;
       cout &lt;&lt; &quot; \n 2. BINARY &quot;;
       cout &lt;&lt; &quot;\n\n &quot;; cin  &gt;&gt; ASCIIBINARYzahl;

		switch(ASCIIBINARYzahl) {
   case 1:  
      ASCIIBINARY = (&quot;ASCII&quot;);
      break;
   case 2:
      ASCIIBINARY = (&quot;BINARY&quot;);
      break;
   default: // sonst
      return 0;
   }

       //DATASET type wählen

       cout &lt;&lt; &quot; \n Bitte Datei Art wählen &quot;;
       cout &lt;&lt; &quot; \n 1. STRUCTURED_POINTS &quot;;
       cout &lt;&lt; &quot; \n 2. STRUCTURED_GRID &quot;;
       cout &lt;&lt; &quot; \n 3. UNSTRUCTURED_GRID &quot;;
       cout &lt;&lt; &quot; \n 4. POLYDATA &quot;;
       cout &lt;&lt; &quot; \n 5. RECTILINEAR_GRID &quot;;
       cout &lt;&lt; &quot; \n 6. FIELD &quot;;
       cout &lt;&lt; &quot;\n\n &quot;; cin  &gt;&gt; Dateieingabe;

/*Dataset attributes. The number of data
items n of each type must match the number
of points or cells in the dataset. (If type is
FIELD, point and cell data should be omitted.
*/

  string Datasetattributes[]={&quot;STRUCTURED_POINTS&quot;,&quot;STRUCTURED_GRID&quot;,&quot;UNSTRUCTURED_GRID&quot;,&quot;POLYDATA&quot;,&quot;RECTILINEAR_GRID&quot;,&quot;FIELD&quot;};
if(Dateieingabe&lt;=6)
  Dataseteingabe = Datasetattributes[Dateieingabe-1];
else return 0;

if (Dateieingabe == 4)

       cout &lt;&lt; &quot; \n Bitte POLYDATA wählen &quot;;
       cout &lt;&lt; &quot; \n 1. POINTS &quot;;
       cout &lt;&lt; &quot; \n 2. VERTICES &quot;;
       cout &lt;&lt; &quot; \n 3. LINES &quot;;
       cout &lt;&lt; &quot; \n 4. POLYGONS &quot;;
       cout &lt;&lt; &quot; \n 5. TRIANGLE_STRIPS &quot;;
       cout &lt;&lt; &quot;\n\n &quot;; cin &gt;&gt; PolydataZahl;

  string polytypes[]={&quot;POINTS&quot;,&quot;VERTICES&quot;,&quot;LINES&quot;,&quot;TRIANGLE_STRIPS&quot;};
if(PolydataZahl&lt;=5)
  polydata = polytypes[PolydataZahl-1];
else return 0;

      cout &lt;&lt; &quot; \n Bitte Anzahl der Points eingeben \n&quot;;
      cout &lt;&lt; &quot; \n &quot;; cin  &gt;&gt; PointAnzahl;
      cout &lt;&lt; &quot; \n Bitte Pointart eingeben \n&quot;;
      cout &lt;&lt; &quot;\n &quot;; cin &gt;&gt; Pointart;

      int x;
      x = PointAnzahl * 3;
      cout &lt;&lt; &quot;\nJetzt bitte &quot; &lt;&lt; x &lt;&lt; &quot; &quot; &lt;&lt; polydata &lt;&lt; &quot; eingeben&quot;;

             for (i = 0; i &lt;= x ; i++)
 {

  cout &lt;&lt; &quot;\n&quot;;
  cin &gt;&gt; array[i];

 } 

    string pfad2 = pfad + EingabeName + VTK;  
    pfad2.c_str(); //steht dann für char

 {

  ofstream myFile;
  myFile.open (pfad2.c_str());

if (myFile)
{ 

     myFile &lt;&lt; vtkversion &lt;&lt; space &lt;&lt; version &lt;&lt; null &lt;&lt;  enter &lt;&lt; ProjektName &lt;&lt; enter &lt;&lt; ASCIIBINARY &lt;&lt; enter &lt;&lt; dataset &lt;&lt; space &lt;&lt; Dataseteingabe &lt;&lt; enter &lt;&lt; polydata &lt;&lt; space &lt;&lt; PointAnzahl &lt;&lt; space &lt;&lt; Pointart &lt;&lt;    endl;

for (i=0; i&lt; PointAnzahl; i++)
 {
          for (int j = 1; j&lt;=3; j++)
          {
             myFile &lt;&lt; array[i*3+j] &lt;&lt; space;
              }
              myFile &lt;&lt; endl;
          }

     myFile.close();
               for (i = 1; i &lt;= x ; i++)
 {

  cout &lt;&lt; i;

 } 

}    
     system(&quot;pause&quot;);

  }

}
</code></pre>
<p>Und das beste es funktioniert ^^ ohne fehler</p>
<p>Hier ne ausgabe als beispiel</p>
<p># vtk DataFile Version 2.0<br />
Test<br />
ASCII<br />
DATASET POLYDATA<br />
POINTS 8 float<br />
&lt;---- Ok das noch falsch aber des weis ich ja wos liegt<br />
0 0 1<br />
0 0 1<br />
1 0 0<br />
1 0 0<br />
0 1 1<br />
0 1 1<br />
1 1 0<br />
1 1 0</p>
<p>_______________________________________________</p>
<p>So da wollt ich jetzt noch fragen da ich ja schon so viele gut tolle tipps gekriegt hab noch mehr ideen? wie die vektoren und die switch und so?<br />
gerne auch &quot;fortgeschrittene Programmiertechniken&quot; komm ich schon mit klar</p>
<p>also würd mich drüber freun</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1333557</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1333557</guid><dc:creator><![CDATA[GT]]></dc:creator><pubDate>Fri, 27 Jul 2007 07:04:33 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Fri, 27 Jul 2007 07:04:26 GMT]]></title><description><![CDATA[<p>Erstmal solltest du die gesamten globalen Strings entsorgen (und die Hilfskonstanten wie space und Co. direkt als String-Literale einsetzen, wo sie gebraucht werden). Außerdem kannst du die Variablendefinitionen auch in der Funktion verteilen (bis zu der Stelle, wo sie wirklich gebraucht werden).</p>
<p>PS: Und da du die Ausgabedaten sowieso von oben nach unten zusammenstellst, kannst du die Daten auch direkt in die Datei schreiben, wenn du sie ermittelt hast <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/1333563</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1333563</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Fri, 27 Jul 2007 07:04:26 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Fri, 27 Jul 2007 07:07:11 GMT]]></title><description><![CDATA[<p>hmmm das ne idee ja</p>
<p>wenn ich sie immer dann rein schreib wenn ichs hab dann hab ich auch kein problem mehr mit den abständen und so weil ich einfach eingabe mach (in file schreiben und jeh nach dem leer oder enter) das gut</p>
<p>und variablen erst definiern wenn ich sie brauch?</p>
<p>also zum ersten mal benutze<br />
gut gut mal schaun</p>
<p>frisch ans werk</p>
<p>Danke führ diese schon sehr früher Hilfestellung</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1333564</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1333564</guid><dc:creator><![CDATA[GT]]></dc:creator><pubDate>Fri, 27 Jul 2007 07:07:11 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Fri, 27 Jul 2007 08:18:48 GMT]]></title><description><![CDATA[<p>Habs jetzt abgeändert</p>
<pre><code class="language-cpp">#include &lt;fstream&gt;
#include &lt;iostream&gt; 
#include &lt;string&gt;
#include&lt;vector&gt;

using namespace std;
int main ( ) {  

	   //Name der Datei unter dem sie dann abgespeichert wird     
	   string EingabeName; 
       cout &lt;&lt; &quot; \n Bitte Name der Datei eingeben \n&quot;;
       cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; EingabeName;
       //Pfad angeben wo datei dann gespeichert wird
	   string pfad;
       cout &lt;&lt; &quot; \n Bitte Pfad eingeben \n&quot;;
       cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; pfad;

	   string VTK = &quot;.vtk&quot;;  
	   string pfad2 = pfad + EingabeName + VTK;  
	   pfad2.c_str(); //steht dann für char

       ofstream myFile;
       myFile.open (pfad2.c_str());

if (myFile)
{ 

      string vtkversion = &quot;# vtk DataFile Version&quot;;
      string null = &quot;.0&quot;;
      string space = &quot; &quot;;
      string enter = &quot;\n&quot;;

      //Wahl der VTK Version 1, 2 oder 3.
	  int version;
      cout &lt;&lt; &quot; \n Bitte VTK Versionsnummer eingeben \n&quot;;
      cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; version;
	  myFile &lt;&lt; vtkversion &lt;&lt; space &lt;&lt; version &lt;&lt; null &lt;&lt; enter;

	  //Name in der Datei z.B. kurze beschreibung (ohne Leerzeichen)!
	  string ProjektName;
      cout &lt;&lt; &quot; \n Bitte Projekt Namen der Datei eingeben \n&quot;;
      cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; ProjektName;
      myFile &lt;&lt; ProjektName &lt;&lt; enter;

      // Wahl zwischen ASCII und BINARY
	  string ASCIIBINARY = &quot;&quot;;
	  int ASCIIBINARYzahl;
      cout &lt;&lt; &quot; \n Bitte zwischen ASCII | BINARY wählen \n&quot;;
      cout &lt;&lt; &quot; \n 1. ASCII &quot;;
      cout &lt;&lt; &quot; \n 2. BINARY &quot;;
      cout &lt;&lt; &quot;\n\n &quot;; cin  &gt;&gt; ASCIIBINARYzahl;

	  switch(ASCIIBINARYzahl) {
   case 1:  
      ASCIIBINARY = (&quot;ASCII&quot;);
      break;
   case 2:
      ASCIIBINARY = (&quot;BINARY&quot;);
      break;
   default: // sonst
      return 0;
                             }
      myFile &lt;&lt; ASCIIBINARY &lt;&lt; enter;
      string dataset = &quot;DATASET&quot;;

      //DATASET type wählen
      int Dateieingabe;
      cout &lt;&lt; &quot; \n Bitte Datei Art wählen &quot;;
      cout &lt;&lt; &quot; \n 1. STRUCTURED_POINTS &quot;;
      cout &lt;&lt; &quot; \n 2. STRUCTURED_GRID &quot;;
      cout &lt;&lt; &quot; \n 3. UNSTRUCTURED_GRID &quot;;
      cout &lt;&lt; &quot; \n 4. POLYDATA &quot;;
      cout &lt;&lt; &quot; \n 5. RECTILINEAR_GRID &quot;;
      cout &lt;&lt; &quot; \n 6. FIELD &quot;;
      cout &lt;&lt; &quot;\n\n &quot;; cin  &gt;&gt; Dateieingabe;

/*Dataset attributes. The number of data
items n of each type must match the number
of points or cells in the dataset. (If type is
FIELD, point and cell data should be omitted.
*/
      string Dataseteingabe;
      string Datasetattributes[]={&quot;STRUCTURED_POINTS&quot;,&quot;STRUCTURED_GRID&quot;,&quot;UNSTRUCTURED_GRID&quot;,&quot;POLYDATA&quot;,&quot;RECTILINEAR_GRID&quot;,&quot;FIELD&quot;};
if(Dateieingabe&lt;=6)
      Dataseteingabe = Datasetattributes[Dateieingabe-1];
else return 0;
      myFile &lt;&lt; dataset &lt;&lt; space &lt;&lt; Dataseteingabe &lt;&lt; enter;

      int PolydataZahl;
if (Dateieingabe == 4)

      cout &lt;&lt; &quot; \n Bitte POLYDATA wählen &quot;;
      cout &lt;&lt; &quot; \n 1. POINTS &quot;;
      cout &lt;&lt; &quot; \n 2. VERTICES &quot;;
      cout &lt;&lt; &quot; \n 3. LINES &quot;;
      cout &lt;&lt; &quot; \n 4. POLYGONS &quot;;
      cout &lt;&lt; &quot; \n 5. TRIANGLE_STRIPS &quot;;
      cout &lt;&lt; &quot;\n\n &quot;; cin &gt;&gt; PolydataZahl;

      string polydata;
      string polytypes[]={&quot;POINTS&quot;,&quot;VERTICES&quot;,&quot;LINES&quot;,&quot;TRIANGLE_STRIPS&quot;};
if(PolydataZahl&lt;=5)
      polydata = polytypes[PolydataZahl-1];
else return 0;

	  int PointAnzahl;
	  string Pointart;
      cout &lt;&lt; &quot; \n Bitte Anzahl der Points eingeben \n&quot;;
      cout &lt;&lt; &quot; \n &quot;; cin  &gt;&gt; PointAnzahl;
      cout &lt;&lt; &quot; \n Bitte Pointart eingeben \n&quot;;
      cout &lt;&lt; &quot;\n &quot;; cin &gt;&gt; Pointart;
	  myFile &lt;&lt; polydata &lt;&lt; space &lt;&lt; PointAnzahl &lt;&lt; space &lt;&lt; Pointart &lt;&lt; enter;
   /*  
	  int x;
	  int i;
	  int array[i];
      x = PointAnzahl * 3;
      cout &lt;&lt; &quot;\nJetzt bitte &quot; &lt;&lt; x &lt;&lt; &quot; &quot; &lt;&lt; polydata &lt;&lt; &quot; eingeben&quot;;

             for (i = 0; i &lt;= x ; i++)
 {
  cout &lt;&lt; &quot;\n&quot;;
  cin &gt;&gt; array[i];
 }

 for (i=0; i&lt; PointAnzahl; i++)
 {
          for (int j = 1; j&lt;=3; j++)
          {
             myFile &lt;&lt; array[i*3+j] &lt;&lt; space;
              }
              myFile &lt;&lt; endl;
          } 
 */
    myFile.close();

}

    system(&quot;pause&quot;);

  }
</code></pre>
<p>der letzte auskommentierte teil der mit der eingabe von array[i] der funktioniert nicht wenns bei der ausführung angelangt istdann stürtzt das programm ab (aber ohne hinweis auf fehler)<br />
nur weis ich nicht warum</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1333636</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1333636</guid><dc:creator><![CDATA[GT]]></dc:creator><pubDate>Fri, 27 Jul 2007 08:18:48 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Fri, 27 Jul 2007 08:29:35 GMT]]></title><description><![CDATA[<p>Da ist ja schon wieder deine VLA-Konstruktion (die immer noch genauso falsch ist wie am Anfang). Und eine Variable anzulegen, nur um sie dann EINMAL auszugeben, halte ich für Verschwendung:</p>
<pre><code class="language-cpp">if (myFile)
{ 
    //Wahl der VTK Version 1, 2 oder 3.
    int version;
    cout &lt;&lt; &quot; \n Bitte VTK Versionsnummer eingeben \n&quot;;
    cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; version;
    myFile &lt;&lt; &quot;# vtk DataFile Version &quot; &lt;&lt; version &lt;&lt; &quot;.0\n&quot;;
...
    //DATASET type wählen
    int Dateieingabe;
    cout &lt;&lt; &quot; \n Bitte Datei Art wählen &quot;;
    cout &lt;&lt; &quot; \n 1. STRUCTURED_POINTS &quot;;
    cout &lt;&lt; &quot; \n 2. STRUCTURED_GRID &quot;;
    cout &lt;&lt; &quot; \n 3. UNSTRUCTURED_GRID &quot;;
    cout &lt;&lt; &quot; \n 4. POLYDATA &quot;;
    cout &lt;&lt; &quot; \n 5. RECTILINEAR_GRID &quot;;
    cout &lt;&lt; &quot; \n 6. FIELD &quot;;
    cout &lt;&lt; &quot;\n\n &quot;; cin  &gt;&gt; Dateieingabe;
    string Datasetattributes[]={&quot;STRUCTURED_POINTS&quot;,&quot;STRUCTURED_GRID&quot;,&quot;UNSTRUCTURED_GRID&quot;,&quot;POLYDATA&quot;,&quot;RECTILINEAR_GRID&quot;,&quot;FIELD&quot;};
    if(Dateieingabe&lt;=6)
        myFile&lt;&lt;&quot;DATASET &quot;&lt;&lt;Datasetattributes[Dateieingabe-1]&lt;&lt;&quot;\n&quot;;
    else
        return 0;
...
</code></pre>
<p>(btw, nur eine Kleinigkeit: Gewöhn dir einen vernünftigen Einrückungsstil an, das erleichtert die Lesbarkeit deines Codes)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1333650</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1333650</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Fri, 27 Jul 2007 08:29:35 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Fri, 27 Jul 2007 08:33:53 GMT]]></title><description><![CDATA[<p>ja ok ich muss mir halt noch einen guten style aneignen naja hoffe das es bisdahin noch geht</p>
<p>und das erste Problem werde ich noch berichtigen aber ich meine das das problem ja hier liegt</p>
<pre><code class="language-cpp">int x;
      int i;
      int array[i];
      x = PointAnzahl * 3;
      cout &lt;&lt; &quot;\nJetzt bitte &quot; &lt;&lt; x &lt;&lt; &quot; &quot; &lt;&lt; polydata &lt;&lt; &quot; eingeben&quot;;

             for (i = 0; i &lt;= x ; i++)
 {
  cout &lt;&lt; &quot;\n&quot;;
  cin &gt;&gt; array[i];
 }

 for (i=0; i&lt; PointAnzahl; i++)
 {
          for (int j = 1; j&lt;=3; j++)
          {
             myFile &lt;&lt; array[i*3+j] &lt;&lt; space;
              }
              myFile &lt;&lt; endl;
          }
</code></pre>
<p>weil ja bis zu der stelle geht alles</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1333657</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1333657</guid><dc:creator><![CDATA[GT]]></dc:creator><pubDate>Fri, 27 Jul 2007 08:33:53 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Fri, 27 Jul 2007 08:34:52 GMT]]></title><description><![CDATA[<p>SORRY</p>
<p>ICH NEHMS ZURÜCK</p>
<p>ich verbessers</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1333659</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1333659</guid><dc:creator><![CDATA[GT]]></dc:creator><pubDate>Fri, 27 Jul 2007 08:34:52 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Fri, 27 Jul 2007 08:51:47 GMT]]></title><description><![CDATA[<p>GT schrieb:</p>
<blockquote>
<p>j...</p>
<pre><code class="language-cpp">int i;
      int array[i];
</code></pre>
<p>...</p>
</blockquote>
<p>Gib's zu: Du willst CStoll in den Wahnsinn treiben.... <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>Ach ja: Als Mitglied kannst Du Deine Posts auch editieren und musst nicht immer neue aufmachen...</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1333680</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1333680</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Fri, 27 Jul 2007 08:51:47 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Fri, 27 Jul 2007 08:51:25 GMT]]></title><description><![CDATA[<p>So jetzt aber</p>
<pre><code class="language-cpp">#include &lt;fstream&gt;
#include &lt;iostream&gt; 
#include &lt;string&gt;
#include&lt;vector&gt;

using namespace std;
int main ( ) {  

	   //Name der Datei unter dem sie dann abgespeichert wird     
	   string EingabeName; 
       cout &lt;&lt; &quot; \n Bitte Name der Datei eingeben \n&quot;;
       cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; EingabeName;
       //Pfad angeben wo datei dann gespeichert wird
	   string pfad;
       cout &lt;&lt; &quot; \n Bitte Pfad eingeben \n&quot;;
       cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; pfad;

	   string VTK = &quot;.vtk&quot;;  
	   string pfad2 = pfad + EingabeName + VTK;  
	   pfad2.c_str(); //steht dann für char

       ofstream myFile;
       myFile.open (pfad2.c_str());

if (myFile)
{ 

      string vtkversion = &quot;# vtk DataFile Version&quot;;
      string null = &quot;.0&quot;;
      string space = &quot; &quot;;
      string enter = &quot;\n&quot;;

      //Wahl der VTK Version 1, 2 oder 3.
	  int version;
      cout &lt;&lt; &quot; \n Bitte VTK Versionsnummer eingeben \n&quot;;
      cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; version;
	  myFile &lt;&lt; vtkversion &lt;&lt; space &lt;&lt; version &lt;&lt; null &lt;&lt; enter;

	  //Name in der Datei z.B. kurze beschreibung (ohne Leerzeichen)!
	  string ProjektName;
      cout &lt;&lt; &quot; \n Bitte Projekt Namen der Datei eingeben \n&quot;;
      cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; ProjektName;
      myFile &lt;&lt; ProjektName &lt;&lt; enter;

      // Wahl zwischen ASCII und BINARY
	  string ASCIIBINARY = &quot;&quot;;
	  int ASCIIBINARYzahl;
      cout &lt;&lt; &quot; \n Bitte zwischen ASCII | BINARY wählen \n&quot;;
      cout &lt;&lt; &quot; \n 1. ASCII &quot;;
      cout &lt;&lt; &quot; \n 2. BINARY &quot;;
      cout &lt;&lt; &quot;\n\n &quot;; cin  &gt;&gt; ASCIIBINARYzahl;

	  switch(ASCIIBINARYzahl) {
   case 1:  
      ASCIIBINARY = (&quot;ASCII&quot;);
      break;
   case 2:
      ASCIIBINARY = (&quot;BINARY&quot;);
      break;
   default: // sonst
      return 0;
                             }
      myFile &lt;&lt; ASCIIBINARY &lt;&lt; enter;
      string dataset = &quot;DATASET&quot;;

      //DATASET type wählen
      int Dateieingabe;
      cout &lt;&lt; &quot; \n Bitte Datei Art wählen &quot;;
      cout &lt;&lt; &quot; \n 1. STRUCTURED_POINTS &quot;;
      cout &lt;&lt; &quot; \n 2. STRUCTURED_GRID &quot;;
      cout &lt;&lt; &quot; \n 3. UNSTRUCTURED_GRID &quot;;
      cout &lt;&lt; &quot; \n 4. POLYDATA &quot;;
      cout &lt;&lt; &quot; \n 5. RECTILINEAR_GRID &quot;;
      cout &lt;&lt; &quot; \n 6. FIELD &quot;;
      cout &lt;&lt; &quot;\n\n &quot;; cin  &gt;&gt; Dateieingabe;

/*Dataset attributes. The number of data
items n of each type must match the number
of points or cells in the dataset. (If type is
FIELD, point and cell data should be omitted.
*/
      string Dataseteingabe;
      string Datasetattributes[]={&quot;STRUCTURED_POINTS&quot;,&quot;STRUCTURED_GRID&quot;,&quot;UNSTRUCTURED_GRID&quot;,&quot;POLYDATA&quot;,&quot;RECTILINEAR_GRID&quot;,&quot;FIELD&quot;};
if(Dateieingabe&lt;=6)
      Dataseteingabe = Datasetattributes[Dateieingabe-1];
else return 0;
      myFile &lt;&lt; dataset &lt;&lt; space &lt;&lt; Dataseteingabe &lt;&lt; enter;

      int PolydataZahl;
if (Dateieingabe == 4)

      cout &lt;&lt; &quot; \n Bitte POLYDATA wählen &quot;;
      cout &lt;&lt; &quot; \n 1. POINTS &quot;;
      cout &lt;&lt; &quot; \n 2. VERTICES &quot;;
      cout &lt;&lt; &quot; \n 3. LINES &quot;;
      cout &lt;&lt; &quot; \n 4. POLYGONS &quot;;
      cout &lt;&lt; &quot; \n 5. TRIANGLE_STRIPS &quot;;
      cout &lt;&lt; &quot;\n\n &quot;; cin &gt;&gt; PolydataZahl;

      string polydata;
      string polytypes[]={&quot;POINTS&quot;,&quot;VERTICES&quot;,&quot;LINES&quot;,&quot;TRIANGLE_STRIPS&quot;};
if(PolydataZahl&lt;=5)
      polydata = polytypes[PolydataZahl-1];
else return 0;

	  int PointAnzahl;
	  string Pointart;
      cout &lt;&lt; &quot; \n Bitte Anzahl der Points eingeben \n&quot;;
      cout &lt;&lt; &quot; \n &quot;; cin  &gt;&gt; PointAnzahl;
      cout &lt;&lt; &quot; \n Bitte Pointart eingeben \n&quot;;
      cout &lt;&lt; &quot;\n &quot;; cin &gt;&gt; Pointart;
	  myFile &lt;&lt; polydata &lt;&lt; space &lt;&lt; PointAnzahl &lt;&lt; space &lt;&lt; Pointart &lt;&lt; enter;

vector&lt;int&gt; Array;
cout &lt;&lt; &quot;Bitte Werte eingeben\n&quot;;
int ArrayWert;

do{
cout &lt;&lt; &quot;Wert (999 = Ende der Eingabe):&quot;;
cin &gt;&gt; ArrayWert;

if(ArrayWert != 999)

Array.push_back(ArrayWert);

} while(ArrayWert != 999);

for (int l=0; l&lt; PointAnzahl; l++)
 {
          for (int j = 1; j&lt;=3; j++)
          {
             myFile &lt;&lt; Array[l*3+j] &lt;&lt; space;
              }
              myFile &lt;&lt; endl;
          } 

    myFile.close();

}

    system(&quot;pause&quot;);

}
</code></pre>
<p>Aber jetzt wenn ich über einen wert komme dann krieg ich wieder das raus</p>
<p># vtk DataFile Version 2.0<br />
TEST<br />
ASCII<br />
DATASET POLYDATA<br />
POINTS 8 float<br />
1 1 1<br />
1 1 1<br />
1 1 0<br />
0 0 0<br />
0 0 0<br />
0 0 0<br />
0 1 1<br />
0 0 1702130553</p>
<p>aber bei geringen werten nicht</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1333684</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1333684</guid><dc:creator><![CDATA[GT]]></dc:creator><pubDate>Fri, 27 Jul 2007 08:51:25 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Fri, 27 Jul 2007 08:53:48 GMT]]></title><description><![CDATA[<p>ja also nicht wirklich ich bin ihm ja für seine hilfe sehr dankbar</p>
<p>ich habs nur voll verplant das ich des ja schon wie bei dem beispiel jetzt geändert hatte</p>
<p>aber jetzt wie eins drüber das problem hmmmm</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1333687</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1333687</guid><dc:creator><![CDATA[GT]]></dc:creator><pubDate>Fri, 27 Jul 2007 08:53:48 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Fri, 27 Jul 2007 09:02:46 GMT]]></title><description><![CDATA[<p>Die Ausgabeschleife erwartet, daß (mindestens) 3*PointAnzahl Werte in deinem vector stehen - wenn du dich also bei der Eingabe verzählst, erhältst du Müll-Daten (oder einen Zugriffsfehler). Und außerdem hast du da noch einen eins-daneben-Fehler in der Ausgabe - ändere die innere Schleife mal auf 'for(j=0;j&lt;3;++j)'.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1333705</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1333705</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Fri, 27 Jul 2007 09:02:46 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Fri, 27 Jul 2007 09:21:50 GMT]]></title><description><![CDATA[<p>So ich mach irgendwie immer die selben fehler</p>
<p>for (int j = 0; j&lt;3; j++) &lt;---- da hatte ich wieder &lt;= und 1 statt 0<br />
aber hast du ja gesagt (nur zur eigenstellungnahme)</p>
<pre><code class="language-cpp">#include &lt;fstream&gt;
#include &lt;iostream&gt; 
#include &lt;string&gt;
#include&lt;vector&gt;

using namespace std;
int main ( ) {  

	   //Name der Datei unter dem sie dann abgespeichert wird     
	   string EingabeName; 
       cout &lt;&lt; &quot; \n Bitte Name der Datei eingeben \n&quot;;
       cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; EingabeName;
       //Pfad angeben wo datei dann gespeichert wird
	   string pfad;
       cout &lt;&lt; &quot; \n Bitte Pfad eingeben \n&quot;;
       cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; pfad;

	   string VTK = &quot;.vtk&quot;;  
	   string pfad2 = pfad + EingabeName + VTK;  
	   pfad2.c_str(); //steht dann für char

       ofstream myFile;
       myFile.open (pfad2.c_str());

if (myFile)
{ 

      string vtkversion = &quot;# vtk DataFile Version&quot;;
      string null = &quot;.0&quot;;
      string space = &quot; &quot;;
      string enter = &quot;\n&quot;;

      //Wahl der VTK Version 1, 2 oder 3.
	  int version;
      cout &lt;&lt; &quot; \n Bitte VTK Versionsnummer eingeben \n&quot;;
      cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; version;
	  myFile &lt;&lt; vtkversion &lt;&lt; space &lt;&lt; version &lt;&lt; null &lt;&lt; enter;

	  //Name in der Datei z.B. kurze beschreibung (ohne Leerzeichen)!
	  string ProjektName;
      cout &lt;&lt; &quot; \n Bitte Projekt Namen der Datei eingeben \n&quot;;
      cout &lt;&lt; &quot; &quot;; cin  &gt;&gt; ProjektName;
      myFile &lt;&lt; ProjektName &lt;&lt; enter;

      // Wahl zwischen ASCII und BINARY
	  string ASCIIBINARY = &quot;&quot;;
	  int ASCIIBINARYzahl;
      cout &lt;&lt; &quot; \n Bitte zwischen ASCII | BINARY wählen \n&quot;;
      cout &lt;&lt; &quot; \n 1. ASCII &quot;;
      cout &lt;&lt; &quot; \n 2. BINARY &quot;;
      cout &lt;&lt; &quot;\n\n &quot;; cin  &gt;&gt; ASCIIBINARYzahl;

	  switch(ASCIIBINARYzahl) {
   case 1:  
      ASCIIBINARY = (&quot;ASCII&quot;);
      break;
   case 2:
      ASCIIBINARY = (&quot;BINARY&quot;);
      break;
   default: // sonst
      return 0;
                             }
      myFile &lt;&lt; ASCIIBINARY &lt;&lt; enter;
      string dataset = &quot;DATASET&quot;;

      //DATASET type wählen
      int Dateieingabe;
      cout &lt;&lt; &quot; \n Bitte Datei Art wählen &quot;;
      cout &lt;&lt; &quot; \n 1. STRUCTURED_POINTS &quot;;
      cout &lt;&lt; &quot; \n 2. STRUCTURED_GRID &quot;;
      cout &lt;&lt; &quot; \n 3. UNSTRUCTURED_GRID &quot;;
      cout &lt;&lt; &quot; \n 4. POLYDATA &quot;;
      cout &lt;&lt; &quot; \n 5. RECTILINEAR_GRID &quot;;
      cout &lt;&lt; &quot; \n 6. FIELD &quot;;
      cout &lt;&lt; &quot;\n\n &quot;; cin  &gt;&gt; Dateieingabe;

/*Dataset attributes. The number of data
items n of each type must match the number
of points or cells in the dataset. (If type is
FIELD, point and cell data should be omitted.
*/
      string Dataseteingabe;
      string Datasetattributes[]={&quot;STRUCTURED_POINTS&quot;,&quot;STRUCTURED_GRID&quot;,&quot;UNSTRUCTURED_GRID&quot;,&quot;POLYDATA&quot;,&quot;RECTILINEAR_GRID&quot;,&quot;FIELD&quot;};
if(Dateieingabe&lt;=6)
      Dataseteingabe = Datasetattributes[Dateieingabe-1];
else return 0;
      myFile &lt;&lt; dataset &lt;&lt; space &lt;&lt; Dataseteingabe &lt;&lt; enter;

      int PolydataZahl;
if (Dateieingabe == 4)

      cout &lt;&lt; &quot; \n Bitte POLYDATA wählen &quot;;
      cout &lt;&lt; &quot; \n 1. POINTS &quot;;
      cout &lt;&lt; &quot; \n 2. VERTICES &quot;;
      cout &lt;&lt; &quot; \n 3. LINES &quot;;
      cout &lt;&lt; &quot; \n 4. POLYGONS &quot;;
      cout &lt;&lt; &quot; \n 5. TRIANGLE_STRIPS &quot;;
      cout &lt;&lt; &quot;\n\n &quot;; cin &gt;&gt; PolydataZahl;

      string polydata;
      string polytypes[]={&quot;POINTS&quot;,&quot;VERTICES&quot;,&quot;LINES&quot;,&quot;TRIANGLE_STRIPS&quot;};
if(PolydataZahl&lt;=5)
      polydata = polytypes[PolydataZahl-1];
else return 0;

	  int PointAnzahl;
	  string Pointart;
      cout &lt;&lt; &quot; \n Bitte Anzahl der Points eingeben \n&quot;;
      cout &lt;&lt; &quot; \n &quot;; cin  &gt;&gt; PointAnzahl;
      cout &lt;&lt; &quot; \n Bitte Pointart eingeben \n&quot;;
      cout &lt;&lt; &quot;\n &quot;; cin &gt;&gt; Pointart;
	  myFile &lt;&lt; polydata &lt;&lt; space &lt;&lt; PointAnzahl &lt;&lt; space &lt;&lt; Pointart &lt;&lt; enter;

vector&lt;int&gt; Array;
cout &lt;&lt; &quot;Bitte Werte eingeben\n&quot;;
int ArrayWert;

do{
cout &lt;&lt; &quot;Wert (999 = Ende der Eingabe):&quot;;
cin &gt;&gt; ArrayWert;

if(ArrayWert != 999)

Array.push_back(ArrayWert);

} while(ArrayWert != 999);

for (int l=0; l&lt; PointAnzahl; l++)
 {
          for (int j = 0; j&lt;3; j++)
          {
             myFile &lt;&lt; Array[l*3+j] &lt;&lt; space;
              }
              myFile &lt;&lt; endl;
          } 

    myFile.close();

}

    system(&quot;pause&quot;);

}
</code></pre>
<p>So gehts</p>
<p>ok da ich ja mülldaten krieg was vollkommen stimmt was ich auch weis wär jetzt meine frage wie ich das verhinder</p>
<p>weil bei meinem anfänglichen Programm hat die eingabe aufforderung ja aufgehört nachdem man den eingabewert mal 3 erreicht hatte da war aber das mit dem array[i]</p>
<p>kann ich des so wie ichs am anfang gamacht hab auch bei der vektor sache einsetzen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1333729</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1333729</guid><dc:creator><![CDATA[GT]]></dc:creator><pubDate>Fri, 27 Jul 2007 09:21:50 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit schleifen Ausgabe on Fri, 27 Jul 2007 09:32:48 GMT]]></title><description><![CDATA[<p>Ja, kannst du machen - du mußt nur vor der Eingabeschleife den vector ausreichend vergrößern:</p>
<pre><code class="language-cpp">vector&lt;int&gt; Array(3*PointAnzahl);
cout &lt;&lt; &quot;Bitte Werte eingeben\n&quot;;
for(int i=0;i&lt;3*PointAnzahl;++i)
  cin&gt;&gt;Array[i];
</code></pre>
<p>(alternativ kannst du auch deine Eingabeschleife nutzen und den vector anschließend resize()n:</p>
<pre><code class="language-cpp">vector&lt;int&gt; Array;
cout &lt;&lt; &quot;Bitte Werte eingeben\n&quot;;
int wert;
do
{
  cin&gt;&gt;wert;
  if(wert!=999)Array.push_back(wert);
}
while(wert!=999 &amp;&amp; Array.size()&lt;3*PointAnzahl/*mehr Werte als Punkte brauchst du nicht*/);
Array.resize(3*PointAnzahl);//füllt die nicht eingegebenen Punkte mit Nullen auf
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1333748</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1333748</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Fri, 27 Jul 2007 09:32:48 GMT</pubDate></item></channel></rss>