<?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[[C++] Kommandozeilen-Parameter (argv and env)]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich wollte fragen wie Ihr die Kommandozeilen-Parameter verarbeitet. Gibts da irgendwelche netten Bibliotheken oder sonst was dafür. Würde mich sehr über eurer Erfahrungen freuen.</p>
<p>Gruß</p>
<p>zyon</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/162434/c-kommandozeilen-parameter-argv-and-env</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Jul 2026 07:12:46 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/162434.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 18 Oct 2006 12:43:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [C++] Kommandozeilen-Parameter (argv and env) on Wed, 18 Oct 2006 12:43:17 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich wollte fragen wie Ihr die Kommandozeilen-Parameter verarbeitet. Gibts da irgendwelche netten Bibliotheken oder sonst was dafür. Würde mich sehr über eurer Erfahrungen freuen.</p>
<p>Gruß</p>
<p>zyon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157073</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157073</guid><dc:creator><![CDATA[zyon]]></dc:creator><pubDate>Wed, 18 Oct 2006 12:43:17 GMT</pubDate></item><item><title><![CDATA[Reply to [C++] Kommandozeilen-Parameter (argv and env) on Wed, 18 Oct 2006 12:44:35 GMT]]></title><description><![CDATA[<p>zyon schrieb:</p>
<blockquote>
<p>Hallo,</p>
<p>ich wollte fragen wie Ihr die Kommandozeilen-Parameter verarbeitet. Gibts da irgendwelche netten Bibliotheken oder sonst was dafür. Würde mich sehr über eurer Erfahrungen freuen.</p>
<p>Gruß</p>
<p>zyon</p>
</blockquote>
<p>getopt()</p>
<p>...kannst aber auch selber was dafür schreiben, musst nur argv etc auslesen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157076</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157076</guid><dc:creator><![CDATA[asdd]]></dc:creator><pubDate>Wed, 18 Oct 2006 12:44:35 GMT</pubDate></item><item><title><![CDATA[Reply to [C++] Kommandozeilen-Parameter (argv and env) on Wed, 18 Oct 2006 12:56:33 GMT]]></title><description><![CDATA[<p>asdd schrieb:</p>
<blockquote>
<p>...kannst aber auch selber was dafür schreiben, musst nur argv etc auslesen</p>
</blockquote>
<p>das ist mir vollkommen klar</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157096</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157096</guid><dc:creator><![CDATA[zyon]]></dc:creator><pubDate>Wed, 18 Oct 2006 12:56:33 GMT</pubDate></item><item><title><![CDATA[Reply to [C++] Kommandozeilen-Parameter (argv and env) on Wed, 18 Oct 2006 13:23:58 GMT]]></title><description><![CDATA[<p>Es gibt dafür selbstverständlich eine Lib, und zwar in Boost. Heißt glaub ich programm options. (die <a href="http://boost.org" rel="nofollow">boost.org</a> Website kann ich zur Zeit leider nicht erreichen)</p>
<p>Die unterstützt dich nicht nur beim verarbeiten sondern auch beim checken von gültigen Parametern und alternativ kann man auch die Params aus einer config-Datei laden und speichern.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157116</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157116</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Wed, 18 Oct 2006 13:23:58 GMT</pubDate></item><item><title><![CDATA[Reply to [C++] Kommandozeilen-Parameter (argv and env) on Wed, 18 Oct 2006 15:56:22 GMT]]></title><description><![CDATA[<p>Ich finde solche Bibliotheken (speziell getopt, was total kryptisch ist) nehmen einem nur Flexibilität und bringens nicht wirklich.</p>
<p>Da scanne ich die Argumente lieber selbst. Ist doch nur ne for-Schleife mit nem switch drin.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157205</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157205</guid><dc:creator><![CDATA[DrGreenthumb]]></dc:creator><pubDate>Wed, 18 Oct 2006 15:56:22 GMT</pubDate></item><item><title><![CDATA[Reply to [C++] Kommandozeilen-Parameter (argv and env) on Wed, 18 Oct 2006 16:32:51 GMT]]></title><description><![CDATA[<p>DrGreenthumb schrieb:</p>
<blockquote>
<p>Ich finde solche Bibliotheken (speziell getopt, was total kryptisch ist) nehmen einem nur Flexibilität und bringens nicht wirklich.</p>
<p>Da scanne ich die Argumente lieber selbst. Ist doch nur ne for-Schleife mit nem switch drin.</p>
</blockquote>
<p>naja...</p>
<p>ist schon etwas komplizierter wenn du n gutes CLI anbieten willst</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157220</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157220</guid><dc:creator><![CDATA[Shade Of Mine]]></dc:creator><pubDate>Wed, 18 Oct 2006 16:32:51 GMT</pubDate></item><item><title><![CDATA[Reply to [C++] Kommandozeilen-Parameter (argv and env) on Wed, 18 Oct 2006 16:58:46 GMT]]></title><description><![CDATA[<p>glaube ich nicht... bin damit bisher jedenfalls immer gut gefahren und biete nur gute CLIs an <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/1157229</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157229</guid><dc:creator><![CDATA[DrGreenthumb]]></dc:creator><pubDate>Wed, 18 Oct 2006 16:58:46 GMT</pubDate></item><item><title><![CDATA[Reply to [C++] Kommandozeilen-Parameter (argv and env) on Wed, 18 Oct 2006 17:00:57 GMT]]></title><description><![CDATA[<p>getopt() und kryptisch? lol!</p>
<p>getopt ist echt bequem. Wenn man erst die manpage/sonstige doku dazu gelesen hat, dann kann man es ainfach benutzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157230</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157230</guid><dc:creator><![CDATA[dfsdfds]]></dc:creator><pubDate>Wed, 18 Oct 2006 17:00:57 GMT</pubDate></item><item><title><![CDATA[Reply to [C++] Kommandozeilen-Parameter (argv and env) on Wed, 18 Oct 2006 19:03:04 GMT]]></title><description><![CDATA[<p>kenne getopt nicht, sehe das nur hin und wieder und frage mich was der komische &quot;xyz:blablub&quot;-String bedeuten soll...</p>
<p>Aber wenn ich mir jetzt dieses Beispiel aus der Manpage ansehe, bestätigt sich nur meine Meinung. Jede Menge getopt-Kram den man erstmal verstehen muss und am Ende hat man immer noch ne Schleife mit nem switch drin.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157279</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157279</guid><dc:creator><![CDATA[DrGreenthumb]]></dc:creator><pubDate>Wed, 18 Oct 2006 19:03:04 GMT</pubDate></item><item><title><![CDATA[Reply to [C++] Kommandozeilen-Parameter (argv and env) on Wed, 18 Oct 2006 19:37:06 GMT]]></title><description><![CDATA[<p>DrGreenthumb schrieb:</p>
<blockquote>
<p>kenne getopt nicht, sehe das nur hin und wieder und frage mich was der komische &quot;xyz:blablub&quot;-String bedeuten soll...</p>
<p>Aber wenn ich mir jetzt dieses Beispiel aus der Manpage ansehe, bestätigt sich nur meine Meinung. Jede Menge getopt-Kram den man erstmal verstehen muss und am Ende hat man immer noch ne Schleife mit nem switch drin.</p>
</blockquote>
<p>Wenn man die Doku net gelesen hat, erscheint es kryptisch. Das ist aber noch einfacher als der formatstring von printf...</p>
<p>getopt ist total bequem.</p>
<p>die einzelnen Buchstaben zeigen die möglichen optionen. und wenn nach einem Buchstaben ein ':' kommt, dann übernimmt diese option auch ein argument. Das wars. Mehr muss man net wissen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157290</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157290</guid><dc:creator><![CDATA[sdfdsf]]></dc:creator><pubDate>Wed, 18 Oct 2006 19:37:06 GMT</pubDate></item><item><title><![CDATA[Reply to [C++] Kommandozeilen-Parameter (argv and env) on Wed, 18 Oct 2006 19:54:52 GMT]]></title><description><![CDATA[<blockquote>
<p>Ich finde solche Bibliotheken (speziell getopt, was total kryptisch ist)</p>
</blockquote>
<blockquote>
<p>kenne getopt nicht</p>
</blockquote>
<p>-voice</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157302</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157302</guid><dc:creator><![CDATA[omg]]></dc:creator><pubDate>Wed, 18 Oct 2006 19:54:52 GMT</pubDate></item><item><title><![CDATA[Reply to [C++] Kommandozeilen-Parameter (argv and env) on Wed, 18 Oct 2006 19:56:21 GMT]]></title><description><![CDATA[<p>Ich benutz boost.program options. Ist anfangs durchaus etwas kryptisch aber wenn man erst einmal verstanden hat wie es funktioniert dann will man nicht mehr ohne.</p>
<blockquote>
<p>Da scanne ich die Argumente lieber selbst. Ist doch nur ne for-Schleife mit nem switch drin.</p>
</blockquote>
<p>Kommt auf die Argumente an. Flags kannst du beispielsweise direkt an eine bool Variable binden.</p>
<pre><code class="language-cpp">(&quot;show-scanned-file,S&quot;, po::bool_switch(&amp;show_scanned_files), 
        &quot;Prints a message before a file is being processed.&quot;)
</code></pre>
<p>Fertig. Kurz und lange Kommandoversion und Eintrag in --help implementiert. Später im Program braucht man nur noch ein if(show_scanned_files) hinein zu hauen und fertig ist der Lack.</p>
<p>Wenn es nun natürlich drum geht eine Liste zu verarbeiten kommst du natürlich nicht um eine Schleife irgendwo herum. Kannst dafür aber auch for_each nehmen.</p>
<p>Das Parsen selbst zu übernehmen ist wesentlich fehleranfälliger und am Ende hat man doch manche Flags weggelassen weil man zu faul war den Parser umzubauen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157304</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157304</guid><dc:creator><![CDATA[Ben04]]></dc:creator><pubDate>Wed, 18 Oct 2006 19:56:21 GMT</pubDate></item><item><title><![CDATA[Reply to [C++] Kommandozeilen-Parameter (argv and env) on Thu, 19 Oct 2006 05:58:47 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>danke für die zahlreichen Informationen. Ich würde gerne die CLI-Application die ich schreibe für Win/*BSD/Linux schreiben. Das sollte eigetlich kein Problem sein.</p>
<p>Jeodoch scheiteret es jetzt an &quot;#include &lt;unistd.h&gt;&quot; -&gt; getopt! Kann ich dieses auch unter win nutzen? Wenn ja wo bekomme ich es her.</p>
<p>gruß</p>
<p>zyon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157382</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157382</guid><dc:creator><![CDATA[zyon]]></dc:creator><pubDate>Thu, 19 Oct 2006 05:58:47 GMT</pubDate></item><item><title><![CDATA[Reply to [C++] Kommandozeilen-Parameter (argv and env) on Thu, 19 Oct 2006 14:27:45 GMT]]></title><description><![CDATA[<p>Nimm doch boost. Windows hat kein getopt, sollte aber auch nicht das Problem sein, für Windows zu kompilieren, wenns nicht zu sehr mit der glibc verwachsen ist.</p>
<p>omg schrieb:</p>
<blockquote>
<blockquote>
<p>Ich finde solche Bibliotheken (speziell getopt, was total kryptisch ist)</p>
</blockquote>
<blockquote>
<p>kenne getopt nicht</p>
</blockquote>
<p>-voice</p>
</blockquote>
<p>ja nee, kenne es gut genug um mir ne Meinung darüber zu bilden.</p>
<p>Wollte aber auch nicht so auf der &quot;kryptik&quot; rumreiten... meine nur, es lohnt einfach nicht. Es sei denn, man will unbedingt, dass auch -ab statt -a -b funktioniert.</p>
<p>Ben04 schrieb:</p>
<blockquote>
<p>Das Parsen selbst zu übernehmen ist wesentlich fehleranfälliger und am Ende hat man doch manche Flags weggelassen weil man zu faul war den Parser umzubauen.</p>
</blockquote>
<p>naja, groß parsen muss man ja nicht. Ist immer das gleiche:</p>
<pre><code>for(char** p=argv+1; *p; ++p)
  if(string(*p)==&quot;-x&quot;) xflag = true;
...
</code></pre>
<p>Das wird auch bei 30 Optionen nicht unübersichtlicher und bleibt einfach erweiterbar.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1157673</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1157673</guid><dc:creator><![CDATA[DrGreenthumb]]></dc:creator><pubDate>Thu, 19 Oct 2006 14:27:45 GMT</pubDate></item></channel></rss>