<?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[argv to string umwandeln]]></title><description><![CDATA[<p>Hallo! Stehe bei einem ziemlich trivialen Problem an, ich weiß nicht wie ich <strong>argv</strong> in einen String bekomme.</p>
<p>Habe folgendes probiert hat funktioniert aber leider nicht</p>
<pre><code class="language-cpp">#include &lt;string&gt;
#include &lt;iostream&gt;

using namespace std;

int main(char ** argv , int argc){

	char p_progName[250] = {&quot; &quot;};

	string progName(p_progName);
	progName = argv; //funktioniert nicht

        cout &lt;&lt; argv &lt;&lt;endl; //funktioniert
</code></pre>
<p>MFG THE_ONE</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/177349/argv-to-string-umwandeln</link><generator>RSS for Node</generator><lastBuildDate>Sat, 27 Jun 2026 19:46:11 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/177349.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 30 Mar 2007 13:32:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to argv to string umwandeln on Fri, 30 Mar 2007 13:32:13 GMT]]></title><description><![CDATA[<p>Hallo! Stehe bei einem ziemlich trivialen Problem an, ich weiß nicht wie ich <strong>argv</strong> in einen String bekomme.</p>
<p>Habe folgendes probiert hat funktioniert aber leider nicht</p>
<pre><code class="language-cpp">#include &lt;string&gt;
#include &lt;iostream&gt;

using namespace std;

int main(char ** argv , int argc){

	char p_progName[250] = {&quot; &quot;};

	string progName(p_progName);
	progName = argv; //funktioniert nicht

        cout &lt;&lt; argv &lt;&lt;endl; //funktioniert
</code></pre>
<p>MFG THE_ONE</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1256015</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1256015</guid><dc:creator><![CDATA[THE_ONE]]></dc:creator><pubDate>Fri, 30 Mar 2007 13:32:13 GMT</pubDate></item><item><title><![CDATA[Reply to argv to string umwandeln on Fri, 30 Mar 2007 13:33:38 GMT]]></title><description><![CDATA[<p>Warum sollte man auch einen Array von Strings in einen String bekommen?</p>
<p>Du kannst natürlich versuchen, <strong>argv[0]</strong> in den String zu bekommen. Das dürfte so wie Du es versuchst klappen. BTW: Wofür ist p_progName?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1256017</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1256017</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Fri, 30 Mar 2007 13:33:38 GMT</pubDate></item><item><title><![CDATA[Reply to argv to string umwandeln on Fri, 30 Mar 2007 13:34:06 GMT]]></title><description><![CDATA[<p>Muss das nicht einmal dereferenziert werden?</p>
<p>Und ist es nicht Übliucherweise umgekehrt, also argc zuerst?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1256018</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1256018</guid><dc:creator><![CDATA[Shinja]]></dc:creator><pubDate>Fri, 30 Mar 2007 13:34:06 GMT</pubDate></item><item><title><![CDATA[Reply to argv to string umwandeln on Fri, 30 Mar 2007 13:41:13 GMT]]></title><description><![CDATA[<p>cout liefert folgende ausgabe:</p>
<pre><code>./mmanage database
0x2
</code></pre>
<p>meine Variante ist eh schlecht, ich wollt zuerst ein stringobjekt anlegen und es dann überschreiben. wie würde man es besser richtiger machen.</p>
<p>LordJaxom schrieb:</p>
<blockquote>
<p>Warum sollte man auch einen Array von Strings in einen String bekommen?</p>
<p>Du kannst natürlich versuchen, <strong>argv[0]</strong> in den String zu bekommen. Das dürfte so wie Du es versuchst klappen. BTW: Wofür ist p_progName?</p>
</blockquote>
<pre><code class="language-cpp">#include &lt;string&gt;
#include &lt;iostream&gt;

using namespace std;

int main(char ** argv , int argc){

	char p_progName[250] = {&quot; &quot;};

	string progName(p_progName);
	progName = argv[0]; //funktioniert nicht

        cout &lt;&lt; argv &lt;&lt;endl; //funktioniert
</code></pre>
<p>das mit <strong>argv[0]</strong> liefert-&gt;</p>
<pre><code>Segmentation fault
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1256023</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1256023</guid><dc:creator><![CDATA[THE_ONE]]></dc:creator><pubDate>Fri, 30 Mar 2007 13:41:13 GMT</pubDate></item><item><title><![CDATA[Reply to argv to string umwandeln on Fri, 30 Mar 2007 13:40:29 GMT]]></title><description><![CDATA[<p>argv basiert auf argc Argumenten, also:</p>
<pre><code class="language-cpp">std::vector&lt;std::string&gt; args;

for(int i = 1; i &lt; argc; ++i) // oder doch &lt;= ?! scheiß teil...
    args.push_back(argv[i]);

// Ausgabe:
for(int i = 0; i &lt; args.length(); ++i)
    cout &lt;&lt; &quot;Argument #&quot; &lt;&lt; i &lt;&lt; &quot;: &quot; &lt;&lt; args[i] &lt;&lt; endl;
</code></pre>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1256027</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1256027</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Fri, 30 Mar 2007 13:40:29 GMT</pubDate></item><item><title><![CDATA[Reply to argv to string umwandeln on Fri, 30 Mar 2007 13:41:14 GMT]]></title><description><![CDATA[<p>THE_ONE schrieb:</p>
<blockquote>
<p>cout liefert folgende ausgabe:</p>
<pre><code>./mmanage database
0x2
</code></pre>
</blockquote>
<p>Und die Erklärung kam von Shinja. Der erste Parameter ist die Anzahl der Parameter (üblicherweise mit argc bezeichent) auch wenn Du es als char** interpretierst. Der Wert bleibt 2. Du hast nämlich 2 Parameter: &quot;./manage&quot; und &quot;database&quot;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1256029</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1256029</guid><dc:creator><![CDATA[tntnet]]></dc:creator><pubDate>Fri, 30 Mar 2007 13:41:14 GMT</pubDate></item><item><title><![CDATA[Reply to argv to string umwandeln on Fri, 30 Mar 2007 14:01:52 GMT]]></title><description><![CDATA[<p>Danke für eure Hilfe:<br />
<strong>argc</strong> und <strong>argv</strong> waren vertauscht<br />
Habs jetzt so:</p>
<pre><code class="language-cpp">#include &lt;string&gt;
#include &lt;iostream&gt;

using namespace std;

int main(int argc,char ** argv){

	string progName(argv[0]);

	cout &lt;&lt; progName &lt;&lt; &quot;&gt;&gt;&quot;&lt;&lt; endl;
}
</code></pre>
<p>MFG THE_ONE</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1256057</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1256057</guid><dc:creator><![CDATA[THE_ONE]]></dc:creator><pubDate>Fri, 30 Mar 2007 14:01:52 GMT</pubDate></item></channel></rss>