<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[fstream - getline Problem]]></title><description><![CDATA[<p>Warum klappt das hier nicht?</p>
<pre><code class="language-cpp">bool streamwork::write_file(const string line,STREAM stream)
{
    if (stream == build)
    {
        m_file.open(m_file_name.c_str(), ios::out | ios::app);
        getline(m_file,line);
        return m_file;
    }
    .....
    ......
    .......
}
</code></pre>
<p>m_file ist eine fstream Elementvariable.</p>
<p>ERROR:</p>
<blockquote>
<p>Project : Console application<br />
Compiler : GNU GCC Compiler (called directly)<br />
Directory : H:\C++ Projekte\Finanzplaner CB\<br />
--------------------------------------------------------------------------------<br />
Switching to target: default<br />
Compiling: streamwork.cpp<br />
streamwork.cpp: In member function <code>bool streamwork::write_file(std::string, STREAM)': streamwork.cpp:15: error: no matching function for call to</code>getline(std::fstream&amp;, const std::string&amp;)'<br />
Process terminated with status 1 (0 minutes, 0 seconds)</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/topic/212329/fstream-getline-problem</link><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 23:02:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/212329.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 04 May 2008 20:53:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to fstream - getline Problem on Sun, 04 May 2008 20:53:32 GMT]]></title><description><![CDATA[<p>Warum klappt das hier nicht?</p>
<pre><code class="language-cpp">bool streamwork::write_file(const string line,STREAM stream)
{
    if (stream == build)
    {
        m_file.open(m_file_name.c_str(), ios::out | ios::app);
        getline(m_file,line);
        return m_file;
    }
    .....
    ......
    .......
}
</code></pre>
<p>m_file ist eine fstream Elementvariable.</p>
<p>ERROR:</p>
<blockquote>
<p>Project : Console application<br />
Compiler : GNU GCC Compiler (called directly)<br />
Directory : H:\C++ Projekte\Finanzplaner CB\<br />
--------------------------------------------------------------------------------<br />
Switching to target: default<br />
Compiling: streamwork.cpp<br />
streamwork.cpp: In member function <code>bool streamwork::write_file(std::string, STREAM)': streamwork.cpp:15: error: no matching function for call to</code>getline(std::fstream&amp;, const std::string&amp;)'<br />
Process terminated with status 1 (0 minutes, 0 seconds)</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1503341</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503341</guid><dc:creator><![CDATA[Stromberg]]></dc:creator><pubDate>Sun, 04 May 2008 20:53:32 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Sun, 04 May 2008 21:05:43 GMT]]></title><description><![CDATA[<p>Der Compiler beschwert sich, weil <code>std::getline</code> als zweiten Parameter eine Referenz auf einen <code>std::string</code> erwartet, in den dann auch die aktuell eingelesene Zeile geschrieben werden kann.</p>
<p>Da Du aber in Deinen Funktionsparametern von <code>write_file</code> eine konstante Kopie von <code>line</code> erwartest (was in der Form sowieso unnötig ist, da Du Kopien von Haus aus nicht verändern kannst, und diese deshalb nicht als <code>const</code> deklarieren musst), schlägt auch <code>std::getline</code> fehl, da <code>line</code> natürlich beschreibbar sein muss.</p>
<p>Da:</p>
<pre><code class="language-cpp">bool streamwork::write_file(const string line,STREAM stream)
</code></pre>
<p>Wenn Du eine Referenz auf <code>line</code> übergibst, kann dann auch in diesen String geschrieben werden. (Falls das so vorgesehen ist von Dir). Also so:</p>
<pre><code class="language-cpp">bool streamwork::write_file(string &amp;line,STREAM stream)
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1503345</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503345</guid><dc:creator><![CDATA[mikey]]></dc:creator><pubDate>Sun, 04 May 2008 21:05:43 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Sun, 04 May 2008 21:18:10 GMT]]></title><description><![CDATA[<p>Und warum gehts jetzt nicht:</p>
<pre><code class="language-cpp">#include &quot;streamwork.hpp&quot;
#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
using namespace std;

bool streamwork::write_file(const string &amp;line,STREAM stream)
{
    if (stream == build)
    {
        m_file.open(m_file_name.c_str(), ios::out | ios::app);
        getline(line,m_file); //vertauscht
        return m_file;
    }
}
</code></pre>
<p>Project : Console application<br />
Compiler : GNU GCC Compiler (called directly)<br />
Directory : H:\C++ Projekte\Finanzplaner CB\<br />
--------------------------------------------------------------------------------<br />
Switching to target: default<br />
Compiling: streamwork.cpp<br />
streamwork.cpp: In member function <code>bool streamwork::write_file(std::string&amp;, STREAM)': streamwork.cpp:15: error: no matching function for call to</code>getline(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;&amp;, std::fstream&amp;)'<br />
Process terminated with status 1 (0 minutes, 0 seconds)</p>
<p>line ist nun eine Referenz, und m_file ist nicht konstant.</p>
<p>MfG<br />
Stromberg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1503354</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503354</guid><dc:creator><![CDATA[Stromberg]]></dc:creator><pubDate>Sun, 04 May 2008 21:18:10 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Sun, 04 May 2008 22:04:16 GMT]]></title><description><![CDATA[<p>Lol, warum vertauscht Du denn auch die Parameter bei <code>getline</code> ? <code>std::getline</code> hat folgende Definition, und nach der hat man sich auch zu richten:</p>
<pre><code>istream&amp; getline( istream&amp; is, string&amp; s)
</code></pre>
<p>...und wenn Du nun im ersten Parameter anstatt einen Filestream einen <code>string</code> übergibst, kann das so natürlich nicht funktionieren. So wie Du es im ersten Beispiel gehabt hast, so passt es auch. Oh Gott, schon nach 0:00... in sechs Stunden muss ich raus, also verabschiede ich mich mal. <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1503363</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503363</guid><dc:creator><![CDATA[mikey]]></dc:creator><pubDate>Sun, 04 May 2008 22:04:16 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Mon, 05 May 2008 09:06:36 GMT]]></title><description><![CDATA[<p>Du versuchst in eine <strong>konstante</strong> Variable etwas neues einzulesen. Fällt Dir beim Lesen dieses Satzes auf, was sich da beißt? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1503490</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503490</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Mon, 05 May 2008 09:06:36 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Mon, 05 May 2008 09:31:48 GMT]]></title><description><![CDATA[<p>LordJaxom schrieb:</p>
<blockquote>
<p>Du versuchst in eine <strong>konstante</strong> Variable etwas neues einzulesen. Fällt Dir beim Lesen dieses Satzes auf, was sich da beißt? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
</blockquote>
<p>Nicht nur das...</p>
<p>an dem Namen der Funktion (streamwork::write_file) würde ich tippen das er schreiben will, getline dient aber dem einlesen...</p>
<p>cu André</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1503505</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503505</guid><dc:creator><![CDATA[asc]]></dc:creator><pubDate>Mon, 05 May 2008 09:31:48 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Mon, 05 May 2008 10:06:00 GMT]]></title><description><![CDATA[<p>asc schrieb:</p>
<blockquote>
<p>LordJaxom schrieb:</p>
<blockquote>
<p>Du versuchst in eine <strong>konstante</strong> Variable etwas neues einzulesen. Fällt Dir beim Lesen dieses Satzes auf, was sich da beißt? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
</blockquote>
<p>Nicht nur das...</p>
<p>an dem Namen der Funktion (streamwork::write_file) würde ich tippen das er schreiben will, getline dient aber dem einlesen...</p>
<p>cu André</p>
</blockquote>
<p>ios::out | ios::app implizieren das auch...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1503517</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503517</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Mon, 05 May 2008 10:06:00 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Mon, 05 May 2008 12:01:27 GMT]]></title><description><![CDATA[<p>Also wenn ich dass richtig verstanden habe, kann man mit geline nur aus einer Datei AUSLESEN...und nicht in eine Datei etwas REINSCHREIBEN?<br />
Somit:<br />
getline(Objekt wo eine Zeile rausgelesen wird, Hier wird die rausgelesene Zeile dann gespeichert)</p>
<p>Richtig?</p>
<p>Weil ich hab gedacht mit getline kann man auch etwas Zeilenweise in eine Datei reinschreiben.</p>
<p>MfG<br />
Stromberg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1503590</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503590</guid><dc:creator><![CDATA[Stromberg]]></dc:creator><pubDate>Mon, 05 May 2008 12:01:27 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Mon, 05 May 2008 15:39:56 GMT]]></title><description><![CDATA[<p>Stromberg schrieb:</p>
<blockquote>
<p>Also wenn ich dass richtig verstanden habe, kann man mit geline nur aus einer Datei AUSLESEN...und nicht in eine Datei etwas REINSCHREIBEN?</p>
</blockquote>
<p>Was impliziert den der Name &quot;getline&quot; anderes? ;p</p>
<p>Stromberg schrieb:</p>
<blockquote>
<p>Weil ich hab gedacht mit getline kann man auch etwas Zeilenweise in eine Datei reinschreiben.</p>
</blockquote>
<p>Nein, hier kannst du aber einfach Streamoperationen nehmen...</p>
<pre><code class="language-cpp">m_file &lt;&lt; line &lt;&lt; std::endl;
</code></pre>
<p>cu André</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1503767</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503767</guid><dc:creator><![CDATA[asc]]></dc:creator><pubDate>Mon, 05 May 2008 15:39:56 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Fri, 16 May 2008 07:33:00 GMT]]></title><description><![CDATA[<p>Wie mach ich das denn mit getline wenn ich nur zb. die zweite Zeile eines txt-Dokuments auslesen will?<br />
also</p>
<pre><code class="language-cpp">char engvok[200];
char gervok[200];
ifstream InFile;
    InFile.open(pszDATEI);
        if (!InFile)
    {
        cout &lt;&lt; &quot;Fehler beim Oeffnen der Datei!\n&quot;;
        exit(1);
    }

    InFile &gt;&gt; engvok &gt;&gt; gervok;

        InFile.close();
</code></pre>
<p>Der getline-Befehl muss ja anscheinend dem InFile &gt;&gt;... folgen, da dieser ja die erste Zeile ausliest. Wie muss denn dann der getline-Befehl für die zweite zeile lauten?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1510220</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1510220</guid><dc:creator><![CDATA[Chrisl]]></dc:creator><pubDate>Fri, 16 May 2008 07:33:00 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Fri, 16 May 2008 07:36:15 GMT]]></title><description><![CDATA[<p>Ruf doch einfach zweimal getline auf. Dann hast du auch zwei Zeilen eingelesen. Die erste Zeile kannst du dann selber auseinander nehmen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1510224</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1510224</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Fri, 16 May 2008 07:36:15 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Sat, 17 May 2008 08:59:13 GMT]]></title><description><![CDATA[<p>Hmm , irgendwie bekomm ich das net hin. Wie sage kann ich mir denn mit getline nur Zeile 3, zum Beispiel, auslesen lassen?<br />
Hab bisher gut erklärte Lösung gefunden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1510897</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1510897</guid><dc:creator><![CDATA[Chrisl]]></dc:creator><pubDate>Sat, 17 May 2008 08:59:13 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Sat, 17 May 2008 09:06:44 GMT]]></title><description><![CDATA[<p>Wenn du bereits eine gut erklärte Lösung gefunden hast ist es ja ok. <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="🙂"
    /><br />
Du kannst nicht nur die dritte Zeile einlesen. Du musst immer bis zur dritten Zeile einlesen (also 3mal getline).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1510898</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1510898</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Sat, 17 May 2008 09:06:44 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Sat, 17 May 2008 09:18:57 GMT]]></title><description><![CDATA[<p>Upps <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
Dann versuch ich das mal. Ich hoffe, ich hab keine Problem dabei.<br />
Danke für die schnelle Antwort.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1510907</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1510907</guid><dc:creator><![CDATA[Chrisl]]></dc:creator><pubDate>Sat, 17 May 2008 09:18:57 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Sat, 17 May 2008 20:22:50 GMT]]></title><description><![CDATA[<p>Hmm, ich habs zwar jetzt hinbekommen, dass mir verschieden Zeilen ausgelesen werden. Nur ist das bei einem txt-Dokument mit einer hohen Zeilenanzahl, sehr mühselig, für jede Zeile eine neue Variable zu definieren und auszulesen:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;

using namespace std;
char engvok[256];
char gervok[256];
const char* const pszDATEI = &quot;vok_db.txt&quot;;
int main() {
            string a,b,c,...           

    ifstream InFile;

    InFile.open(pszDATEI);
        if (!InFile)
    {
        cout &lt;&lt; &quot;Fehler beim Oeffnen der Datei!\n&quot;;
        exit(1);
    }

    getline(InFile, a);
    getline(InFile, b);
    getline(InFile, c);
...

        InFile.close();

cout&lt;&lt;a&lt;&lt;&quot;\n&quot;&lt;&lt;b&lt;&lt;&quot;\n&quot;&lt;&lt;c&lt;&lt;&quot;\n&quot;...;
system(&quot;Pause&quot;);
}
</code></pre>
<p>Gibt es da keine einfachere und elegantere Lösung als diese?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1511213</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1511213</guid><dc:creator><![CDATA[Chrisl]]></dc:creator><pubDate>Sat, 17 May 2008 20:22:50 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Sat, 17 May 2008 21:23:01 GMT]]></title><description><![CDATA[<p>Wie wäres es mit einer Schlaufe + Array/std::vector?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1511248</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1511248</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sat, 17 May 2008 21:23:01 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Sun, 18 May 2008 09:29:02 GMT]]></title><description><![CDATA[<p>Und wie würde das denn dann aussehen? Weil ich hab ehrlich gesagt keine Ahnung, wie ich das mit dem Array machen soll...<br />
Mit der Schleife, das ist das kleinere Problem, denke ich.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1511348</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1511348</guid><dc:creator><![CDATA[Chrisl]]></dc:creator><pubDate>Sun, 18 May 2008 09:29:02 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Sun, 18 May 2008 11:54:10 GMT]]></title><description><![CDATA[<p>Ein Array von strings?</p>
<pre><code class="language-cpp">std::string vokabels[1000]; // 1000 Vokabeln
std::vector&lt;std::string&gt; vokabels2; // Dynamisches Array
</code></pre>
<p>Du kannst dann ja ganz einfach auf die strings zugreifen.</p>
<pre><code class="language-cpp">for (int i = 0; i &lt; 1000; i++)
    getline (InFile,vokabels[i]);
</code></pre>
<p>So was in der Art.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1511468</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1511468</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sun, 18 May 2008 11:54:10 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Sun, 18 May 2008 15:00:04 GMT]]></title><description><![CDATA[<p>Super! Danke <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="🙂"
    /><br />
Auch gut, dass du das kommentiert hast. Jetzt gehts glaub ich auch wieder voran mit dem Programm.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1511608</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1511608</guid><dc:creator><![CDATA[Chrisl]]></dc:creator><pubDate>Sun, 18 May 2008 15:00:04 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Sun, 18 May 2008 19:54:17 GMT]]></title><description><![CDATA[<p>Mit dem vector klappt das aber irgendwie nicht ganz, Der gibt mir den Fehler aus, dass vector nicht in dem Namensraum von std liegt...<br />
Muss ich da noch etwas oben hinschreiben? Weil eigentlich verwende ich ja</p>
<pre><code class="language-cpp">using namespace std
</code></pre>
<p>Edit: Habs jetzt, weiß was falsch war.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1511802</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1511802</guid><dc:creator><![CDATA[Chrisl]]></dc:creator><pubDate>Sun, 18 May 2008 19:54:17 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Mon, 19 May 2008 13:18:41 GMT]]></title><description><![CDATA[<p>Na toll, hab schon wieder ein Problem, bei dem ich keine Lösung weiß...<br />
Diesmal kommt folgende Fehlermeldung:<br />
no match for 'operator&lt;&lt;' in 'std::cout &lt;&lt; vokabels2'<br />
Jedoch weiß ich nicht, was an folgendem Script falsch sein soll:</p>
<pre><code class="language-cpp">std::string vokabels[1000];
std::vector&lt;std::string&gt; vokabels2; 
for (int i = 0; i &lt; 1000; i++)   {                
    getline (InFile,vokabels[i]);                 

}               
        InFile.close();                     
   system(&quot;cls&quot;);               
    cout &lt;&lt;vokabels2&lt;&lt;&quot;\n&quot;;
</code></pre>
<p>Sieht vielleicht irgendjemand den Fehler bei meinem Script?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1512274</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512274</guid><dc:creator><![CDATA[Chrisl]]></dc:creator><pubDate>Mon, 19 May 2008 13:18:41 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Mon, 19 May 2008 14:08:42 GMT]]></title><description><![CDATA[<p>Ich sehe da mehr als einen Fehler.<br />
1. Du liest in vokabels ein willst aber vokabels2 ausgeben, welches gar nicht gefüllt ist. Was genau willst du eigentlich?<br />
2.</p>
<pre><code class="language-cpp">cout &lt;&lt;vokabels2&lt;&lt;&quot;\n&quot;;
</code></pre>
<p>Es existiert kein Ausgabeoperator für vector&lt;string&gt;. Das kannst du aber schön in einer Schleife machen (gibt noch mehr Möglichkeiten).<br />
also</p>
<pre><code class="language-cpp">std::vector&lt;std::string&gt; vokabels2;
std::string tstr;
for (int i = 0; i &lt; 1000; i++)   {                
    getline (InFile,tstr);     // in temporäre variable einlesen            
    vokabels2.push_back(tstr); // in den vector kopieren                                          
}              
InFile.close();   // nicht zwingend nötig                 
system(&quot;cls&quot;);
size_t size = vokabels2.size(); //Größe des vectors feststellen
for( size_t i=0; i&lt;size; ++i)             
    cout &lt;&lt; vokabels2[i] &lt;&lt;&quot;\n&quot;; // einzelne Elemente ausgeben
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1512304</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512304</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Mon, 19 May 2008 14:08:42 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Mon, 19 May 2008 14:16:34 GMT]]></title><description><![CDATA[<p>Danke für die Lösung. Man lernt ja bekanntlich immer dazu, und ich merke, dass das bei mir noch sehr viel ist, was ich zu lernen habe <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/1512309</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512309</guid><dc:creator><![CDATA[Chrisl]]></dc:creator><pubDate>Mon, 19 May 2008 14:16:34 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Mon, 19 May 2008 18:13:30 GMT]]></title><description><![CDATA[<p>Also so langsam frage ich mich, ob ich nicht einen einfachen Taschenrechner als Projekt(Schule) abgeben soll...<br />
Irgendwie ist bei mir der Wurm drin. Mein neuestes Problem ist, dass die Zeilen zwar ausgelesen werden, aber direkt danach wieder verschwinden. D.h. ich seh für einen ganz kurzen Moment meine Liste, bevor sie wieder verschwindet...<br />
Kann es daran legen, dass alles nur temporär gespeichert wird, und direkt danach wieder überschrieben bzw. gelöscht wird? Wenn ja, wie kann ich denn dann die Daten festhalten?<br />
Hier mal das \1:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;vector&gt;

using namespace std; 
char engvok[200]; 
char gervok[200];
const char* const pszDATEI = &quot;vok_db.txt&quot;; 
int main() {
    system(&quot;cls&quot;); 
    ifstream InFile;       
    InFile.open(pszDATEI); 
        if (!InFile)       
    {
        cout &lt;&lt; &quot;Fehler beim Oeffnen der Datei!\n&quot;; 
        exit(1);                                    
    }    
std::vector&lt;std::string&gt; vokabels2; // Dynamisches Array 
std::string tstr;                                  
for (int i = 0; i &lt; 1000; i++)   {           
    getline (InFile,tstr);                         // in temporäre variable einlesen 
    vokabels2.push_back(tstr);                     // in den vector kopieren   
}               
       InFile.close();                            
       system(&quot;cls&quot;);
   size_t size = vokabels2.size();                 // Größe des Vektors 
   for(size_t i=0; i&lt;size; ++i) 
       cout &lt;&lt;vokabels2[i]&lt;&lt;&quot;\n&quot;;                  

   system(&quot;Pause&quot;);                                
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1512518</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512518</guid><dc:creator><![CDATA[Chrisl]]></dc:creator><pubDate>Mon, 19 May 2008 18:13:30 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Mon, 19 May 2008 20:15:35 GMT]]></title><description><![CDATA[<p>Ich sehe da kein Fehler, ausser, dass du &lt;string&gt; inkludieren und das ganez NICHT Script nennen solltest. <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="😉"
    /><br />
Sag dem Programm, Quellcode, Code oder so, aber bitte nicht SCRIPT..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1512604</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512604</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Mon, 19 May 2008 20:15:35 GMT</pubDate></item><item><title><![CDATA[Reply to fstream - getline Problem on Tue, 20 May 2008 14:59:37 GMT]]></title><description><![CDATA[<p>Danke für die Belehrung ;).<br />
Nur komm ich leider nun einfach nicht weiter mit meinem Programm. Gibt es vielleicht sonst noch etwas einfaches konsolenbasiertes zu programmieren auf der Schwierigkeitsebene eines Taschenrechners ungefähr?<br />
Weil ich habe einfach zu viele Probleme mit dem Vokabelprogramm...<br />
Oder hat nicht einer zufällig noch ein Vokabelprogramm &quot;herumliegen&quot;, welches Vokabeln aus einer txt-Datei nimmt, die komplette txt-Datei ausliest, wo man Vokabeln hinzufügen kann, und wo man halt abgefragt wird???</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1513108</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1513108</guid><dc:creator><![CDATA[Chrisl]]></dc:creator><pubDate>Tue, 20 May 2008 14:59:37 GMT</pubDate></item></channel></rss>