<?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[ein einziges wort von einem file zu lesen]]></title><description><![CDATA[<p>Hallo ich lerne jetyt grade C++ , und ich habe es grade geschafft mit die klasse fstream , in einem file zu schreiben und von dem zu lesen ,</p>
<p>ales funktioniert aber jetzt dass ich eine ganze Zeile lese !!</p>
<p>kann ich nicht ein wort lese also bis &quot; &quot; und es in einem String speichern ??</p>
<p>bei mir sieht der Code grade so</p>
<pre><code>ifstream myfile (&quot;example.txt&quot;);
  if (myfile.is_open())
  {
    while (! myfile.eof() )
    {
      getline (myfile,line);
      cout &lt;&lt; line &lt;&lt; endl;
    }
    myfile.close();
  }

  else cout &lt;&lt; &quot;Unable to open file&quot;;
</code></pre>
<p>kann mir vielleicht jemand helfen ?</p>
<p>Danke im Voraus</p>
<p>Eure eliaa</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/149365/ein-einziges-wort-von-einem-file-zu-lesen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Sep 2026 05:27:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/149365.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 05 Jun 2006 14:57:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ein einziges wort von einem file zu lesen on Mon, 05 Jun 2006 14:57:57 GMT]]></title><description><![CDATA[<p>Hallo ich lerne jetyt grade C++ , und ich habe es grade geschafft mit die klasse fstream , in einem file zu schreiben und von dem zu lesen ,</p>
<p>ales funktioniert aber jetzt dass ich eine ganze Zeile lese !!</p>
<p>kann ich nicht ein wort lese also bis &quot; &quot; und es in einem String speichern ??</p>
<p>bei mir sieht der Code grade so</p>
<pre><code>ifstream myfile (&quot;example.txt&quot;);
  if (myfile.is_open())
  {
    while (! myfile.eof() )
    {
      getline (myfile,line);
      cout &lt;&lt; line &lt;&lt; endl;
    }
    myfile.close();
  }

  else cout &lt;&lt; &quot;Unable to open file&quot;;
</code></pre>
<p>kann mir vielleicht jemand helfen ?</p>
<p>Danke im Voraus</p>
<p>Eure eliaa</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1071690</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1071690</guid><dc:creator><![CDATA[eliaa]]></dc:creator><pubDate>Mon, 05 Jun 2006 14:57:57 GMT</pubDate></item><item><title><![CDATA[Reply to ein einziges wort von einem file zu lesen on Mon, 05 Jun 2006 14:59:06 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">std::string wort;
myfile &gt;&gt; wort;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1071692</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1071692</guid><dc:creator><![CDATA[ant wort]]></dc:creator><pubDate>Mon, 05 Jun 2006 14:59:06 GMT</pubDate></item><item><title><![CDATA[Reply to ein einziges wort von einem file zu lesen on Mon, 05 Jun 2006 15:49:28 GMT]]></title><description><![CDATA[<p>Die STL bietet auch eine schöne Möglichkeit eine Datei in Wörter auseinanderzunehmen:</p>
<pre><code class="language-cpp">char *infile = argv[1];
    char *outfile = argv[2];

    list&lt;string&gt; words;
    string word;

    ifstream ifs;
    ifs.open( infile);
    if (! ifs) {
        cerr &lt;&lt; &quot;cannot open file &quot; &lt;&lt; infile &lt;&lt; &quot; for input\n&quot;;
        exit(1);
    }

   while (ifs &gt;&gt; word) {
        words.push_back( word);
    }

    if (! ifs.eof()) {
        cerr &lt;&lt; &quot;error while reading from file &quot; &lt;&lt; infile &lt;&lt; endl;
        exit(1);
    }
    ifs.close();

    words.sort();
    list&lt;string&gt;::iterator p = unique( words.begin(), words.end());
    words.erase(p, words.end());

    ofstream ofs;
    ofs.open( outfile);
    if (! ofs) {
        cerr &lt;&lt; &quot;cannot open file &quot; &lt;&lt; outfile &lt;&lt; &quot; for output\n&quot;;
        exit(1);
    }
    list&lt;string&gt;::iterator iword;
    for (iword = words.begin(); iword != words.end(); ++iword) {
        ofs &lt;&lt; *iword &lt;&lt; endl;
    }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1071741</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1071741</guid><dc:creator><![CDATA[winexec*]]></dc:creator><pubDate>Mon, 05 Jun 2006 15:49:28 GMT</pubDate></item></channel></rss>