<?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[Konsolen Befehle mit Zahleneingabe - Erkennung]]></title><description><![CDATA[<p>Morgen <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>Ich schreibe gerade an meiner &quot;Ingame&quot; Konsole, und überlege gerade wie man am besten einen Befehl mit dem Format &quot;set_xyz 1000&quot; auswerten kann.</p>
<pre><code>if(meinString.find(m.Commands.at(0))) == 0)
</code></pre>
<p>Damit kann ich ja relativ gut überprüfen ob &quot;set_xyz&quot; der Anfang des Strings ist, aber ich weiß nicht wie ich jetzt die Zahl dahinter auswerten kann.</p>
<p>jemand eine Idee?</p>
<p>Gruß, Chris</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/316971/konsolen-befehle-mit-zahleneingabe-erkennung</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Jul 2026 13:43:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/316971.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 23 May 2013 05:31:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Konsolen Befehle mit Zahleneingabe - Erkennung on Thu, 23 May 2013 05:31:39 GMT]]></title><description><![CDATA[<p>Morgen <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>Ich schreibe gerade an meiner &quot;Ingame&quot; Konsole, und überlege gerade wie man am besten einen Befehl mit dem Format &quot;set_xyz 1000&quot; auswerten kann.</p>
<pre><code>if(meinString.find(m.Commands.at(0))) == 0)
</code></pre>
<p>Damit kann ich ja relativ gut überprüfen ob &quot;set_xyz&quot; der Anfang des Strings ist, aber ich weiß nicht wie ich jetzt die Zahl dahinter auswerten kann.</p>
<p>jemand eine Idee?</p>
<p>Gruß, Chris</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2325395</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2325395</guid><dc:creator><![CDATA[cl90]]></dc:creator><pubDate>Thu, 23 May 2013 05:31:39 GMT</pubDate></item><item><title><![CDATA[Reply to Konsolen Befehle mit Zahleneingabe - Erkennung on Thu, 23 May 2013 07:04:26 GMT]]></title><description><![CDATA[<p>Hi Chris,</p>
<p>cl90 schrieb:</p>
<blockquote>
<pre><code>if(meinString.find(m.Commands.at(0))) == 0)
</code></pre>
</blockquote>
<p>weiß nicht wofür das gut sein soll.<br />
Dein von Dir beschriebenes Problem kann man z.B. so lösen - indem man die Information einfach von der Konsole einliest (ich unterstelle, es ist eine Konsolen-Applikation und Lesen von <code>cin</code> ist möglich):</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;

int main()
{
    using namespace std;
    for( string command; cout &lt;&lt; &quot;&gt; &quot;, cin &gt;&gt; command; cin.clear(), cin.ignore(999,'\n') )
    {
        if( command == &quot;set_xyz&quot; )
        {
            int zahl;
            if( cin &gt;&gt; zahl ) // &lt;=== hier liest Du die Zahl
            {
                cout &lt;&lt; &quot;    Sie haben 'set_xyz' mit Parameter &quot; &lt;&lt; zahl &lt;&lt; &quot; eingegeben&quot; &lt;&lt; endl;
            }
        }
        else if( command == &quot;&lt;was-anderes&gt;&quot; )
        {
            ; // mach was anderes
        }
        else
            cerr &lt;&lt; &quot;Fehler bei der Eingabe!&quot; &lt;&lt; endl;
    }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2325407</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2325407</guid><dc:creator><![CDATA[Werner_logoff]]></dc:creator><pubDate>Thu, 23 May 2013 07:04:26 GMT</pubDate></item><item><title><![CDATA[Reply to Konsolen Befehle mit Zahleneingabe - Erkennung on Thu, 23 May 2013 07:29:03 GMT]]></title><description><![CDATA[<p>Es ist ein DirectX Programm. die Konsole ist selbst geschrieben, daher kann ich nicht mit cin arbeiten.<br />
Ich erzeuge durch keydown-events einen String.</p>
<p>Daher möchte ich diesen String mit vorgegeben Strings vergleichen, und im gegebenen fall den Wert nach dem Command übernehmen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2325411</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2325411</guid><dc:creator><![CDATA[cl90]]></dc:creator><pubDate>Thu, 23 May 2013 07:29:03 GMT</pubDate></item><item><title><![CDATA[Reply to Konsolen Befehle mit Zahleneingabe - Erkennung on Thu, 23 May 2013 07:40:01 GMT]]></title><description><![CDATA[<p>cl90 schrieb:</p>
<blockquote>
<p>Es ist ein DirectX Programm. die Konsole ist selbst geschrieben, daher kann ich nicht mit cin arbeiten.<br />
Ich erzeuge durch keydown-events einen String.</p>
<p>Daher möchte ich diesen String mit vorgegeben Strings vergleichen, und im gegebenen fall den Wert nach dem Command übernehmen.</p>
</blockquote>
<p>Dann packe den String - ich unterstelle er enthält z.B. &quot;set_xyz 1000&quot; - in einen <code>std::istringstream</code> und lese daraus das Kommando aus - wie gehabt</p>
<pre><code>std::string meinString = &quot;set_xyz 1000&quot;; // Beispiel
    std::istringstream in( meinString ); // erfordert #include &lt;sstream&gt;
    std::string command;
    if( in &gt;&gt; command ) { // 'in' statt 'cin'
        if( command == &quot;set_xyz&quot; ) // ... ab hier so weiter, wie schon im geposteten Code
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2325412</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2325412</guid><dc:creator><![CDATA[Werner_logoff]]></dc:creator><pubDate>Thu, 23 May 2013 07:40:01 GMT</pubDate></item><item><title><![CDATA[Reply to Konsolen Befehle mit Zahleneingabe - Erkennung on Thu, 23 May 2013 07:40:32 GMT]]></title><description><![CDATA[<p>Du könntest die Eingabe in Token zerlegen und anschließend die Token auswerten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2325413</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2325413</guid><dc:creator><![CDATA[DocShoe]]></dc:creator><pubDate>Thu, 23 May 2013 07:40:32 GMT</pubDate></item><item><title><![CDATA[Reply to Konsolen Befehle mit Zahleneingabe - Erkennung on Fri, 24 May 2013 08:48:28 GMT]]></title><description><![CDATA[<p>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 />
ich seh mir das mit den tokens mal an.</p>
<p>edit:<br />
Ich habe jetzt eine schöne variante gefunden:</p>
<pre><code>string buf;
stringstream sstream;
vector&lt;string&gt; token;

sstream &lt;&lt; eingabe;
while(sstream &gt;&gt; buf) token.push_back(buf);
</code></pre>
<p>jetzt kann ich einfach <a href="http://tokens.at" rel="nofollow">tokens.at</a>(0) mit den commands vergleichen und dann <a href="http://tokens.at" rel="nofollow">tokens.at</a>(1) überprüfen und anwenden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2325417</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2325417</guid><dc:creator><![CDATA[cl90]]></dc:creator><pubDate>Fri, 24 May 2013 08:48:28 GMT</pubDate></item></channel></rss>