<?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[Fehler im String?]]></title><description><![CDATA[<p>Hallo,</p>
<p>möchte die IP's und die Hosts im Netz abfragen und habe mir sowas ausgedacht: ich lasse zuerst ein &quot;net view&quot; ausführen schreibe die Rechner in eine Datei namens hosts.txt und lass dann ein &quot;ping&quot; zu diesen Rechnern machen um die IP herauszubekommen. Dir hosts.txt Datei sieht so aus:</p>
<p>PC1<br />
Pc2</p>
<p>Mein Konstrukt sieht so aus:</p>
<pre><code class="language-cpp">ifstream infile_host(&quot;hosts.txt&quot;);
ofstream outfile;
while(!infile_host.eof()){
    getline(infile_host,pc_name);
    pings &lt;&lt; &quot;ping -a -n 1 -l 0.1 -w 0.1 &quot; &lt;&lt; pc_name &lt;&lt; &quot; &gt; ping.txt&quot; &lt;&lt; endl; 
    system(pings.str().c_str());
    cout &lt;&lt; pc_name &lt;&lt; endl;
    }
infile_host.close();
</code></pre>
<p>Das Problem ist, es erkennt PC2 an der Stelle irgendwie nicht. In der ping.txt Datei steht immer der ping zu PC1. Durch das cout kann ich sehen, dass er die beiden PC's liest und auflistet im promt.</p>
<p>Wieso das so ist, verstehe ich nicht. Kann mir einer helfen?</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/256827/fehler-im-string</link><generator>RSS for Node</generator><lastBuildDate>Thu, 10 Sep 2026 23:29:20 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/256827.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 18 Dec 2009 13:06:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fehler im String? on Fri, 18 Dec 2009 13:06:10 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>möchte die IP's und die Hosts im Netz abfragen und habe mir sowas ausgedacht: ich lasse zuerst ein &quot;net view&quot; ausführen schreibe die Rechner in eine Datei namens hosts.txt und lass dann ein &quot;ping&quot; zu diesen Rechnern machen um die IP herauszubekommen. Dir hosts.txt Datei sieht so aus:</p>
<p>PC1<br />
Pc2</p>
<p>Mein Konstrukt sieht so aus:</p>
<pre><code class="language-cpp">ifstream infile_host(&quot;hosts.txt&quot;);
ofstream outfile;
while(!infile_host.eof()){
    getline(infile_host,pc_name);
    pings &lt;&lt; &quot;ping -a -n 1 -l 0.1 -w 0.1 &quot; &lt;&lt; pc_name &lt;&lt; &quot; &gt; ping.txt&quot; &lt;&lt; endl; 
    system(pings.str().c_str());
    cout &lt;&lt; pc_name &lt;&lt; endl;
    }
infile_host.close();
</code></pre>
<p>Das Problem ist, es erkennt PC2 an der Stelle irgendwie nicht. In der ping.txt Datei steht immer der ping zu PC1. Durch das cout kann ich sehen, dass er die beiden PC's liest und auflistet im promt.</p>
<p>Wieso das so ist, verstehe ich nicht. Kann mir einer helfen?</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1824444</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1824444</guid><dc:creator><![CDATA[rasidrasid]]></dc:creator><pubDate>Fri, 18 Dec 2009 13:06:10 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler im String? on Fri, 18 Dec 2009 13:39:09 GMT]]></title><description><![CDATA[<p>Versuchs mal so:</p>
<pre><code class="language-cpp">ifstream infile_host(&quot;hosts.txt&quot;);
ofstream outfile;
while(getline(infile_host,pc_name)){   // Die alte while-Bedingung war falsch.
    stringstream pings &lt;&lt; &quot;ping -a -n 1 -l 0.1 -w 0.1 &quot; &lt;&lt; pc_name &lt;&lt; &quot; &gt; ping.txt&quot; &lt;&lt; endl;   // Mach mal lieber den stringstream lokal, dann ist er auch immer leer.
    system(pings.str().c_str());
    cout &lt;&lt; pc_name &lt;&lt; endl;
    }
infile_host.close();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1824464</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1824464</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 18 Dec 2009 13:39:09 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler im String? on Fri, 18 Dec 2009 13:41:08 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Versuchs mal so:</p>
<pre><code class="language-cpp">ifstream infile_host(&quot;hosts.txt&quot;);
ofstream outfile;
while(getline(infile_host,pc_name)){   // Die alte while-Bedingung war falsch.
    stringstream pings &lt;&lt; &quot;ping -a -n 1 -l 0.1 -w 0.1 &quot; &lt;&lt; pc_name &lt;&lt; &quot; &gt; ping.txt&quot; &lt;&lt; endl;   // Mach mal lieber den stringstream lokal, dann ist er auch immer leer.
    system(pings.str().c_str());
    cout &lt;&lt; pc_name &lt;&lt; endl;
    }
infile_host.close();
</code></pre>
</blockquote>
<p>Warum war die Bedingung falsch? Ich empfand die als richtig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1824467</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1824467</guid><dc:creator><![CDATA[mnmnmn]]></dc:creator><pubDate>Fri, 18 Dec 2009 13:41:08 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler im String? on Fri, 18 Dec 2009 13:51:34 GMT]]></title><description><![CDATA[<p>so hats geklappt, danke.</p>
<pre><code class="language-cpp">ifstream infile_host(&quot;hosts.txt&quot;);
ofstream outfile;
while(getline(infile_host,pc_name)){   // Die alte while-Bedingung war falsch.
      stringstream pings;
     pings &lt;&lt; &quot;ping -a -n 1 -l 0.1 -w 0.1 &quot; &lt;&lt; pc_name &lt;&lt; &quot; &gt; ping.txt&quot; &lt;&lt; endl;   // Mach mal lieber den stringstream lokal, dann ist er auch immer leer.
    system(pings.str().c_str());
    cout &lt;&lt; pc_name &lt;&lt; endl;
    }
infile_host.close();
</code></pre>
<p>Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1824474</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1824474</guid><dc:creator><![CDATA[rasidrasid]]></dc:creator><pubDate>Fri, 18 Dec 2009 13:51:34 GMT</pubDate></item></channel></rss>