<?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[stringstreams + arrays Problem]]></title><description><![CDATA[<p>Hallo zusammen</p>
<p>Da ich immernoch ein Neuling in der C++ Programmierun bin, bitte ich um Verständnis.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;dirent.h&gt;
#include &lt;sstream&gt;
#include &lt;string&gt;

using namespace std;

	int main(int argc, char *argv[])
	{
		//counter
		int ipcount = 0;

		//plugin files
    		char strplugfiles[100];

		//dir handle
    		DIR *dirHandle;
    		struct dirent * dirEntry;

    		dirHandle = opendir(&quot;.&quot;);
    		if (dirHandle) 
		{
      		while (0 != (dirEntry = readdir(dirHandle))) 
			{
				//don't show . and ..
				if(strcmp(dirEntry-&gt;d_name, &quot;.&quot;) == 0 || strcmp(dirEntry-&gt;d_name, &quot;..&quot;) == 0)
				{
					continue;
				}
         	 	//cout &lt;&lt; dirEntry-&gt;d_name &lt;&lt; endl;
         	 	stringstream strstrTemp1; 
         	 	strstrTemp1 &lt;&lt; dirEntry-&gt;d_name;
			strplugfiles[ipcount] &lt;&lt; strstrTemp1;
			cout &lt;&lt; strplugfiles[ipcount] &lt;&lt; endl;

         	 	ipcount++;
       		}
       	closedir(dirHandle);
    	}			

	}
</code></pre>
<p>Ich versuche verzweifelt die Ausgabe von dirEentry in den Array (strplugfiles) zu schreiben. Irgendwie habe ich es mit den Datentypen und ihren Eigenarten noch nicht so ganz.</p>
<p>Danke für Eure Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/164292/stringstreams-arrays-problem</link><generator>RSS for Node</generator><lastBuildDate>Sun, 13 Sep 2026 18:19:49 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/164292.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 06 Nov 2006 20:13:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to stringstreams + arrays Problem on Mon, 06 Nov 2006 20:13:33 GMT]]></title><description><![CDATA[<p>Hallo zusammen</p>
<p>Da ich immernoch ein Neuling in der C++ Programmierun bin, bitte ich um Verständnis.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;dirent.h&gt;
#include &lt;sstream&gt;
#include &lt;string&gt;

using namespace std;

	int main(int argc, char *argv[])
	{
		//counter
		int ipcount = 0;

		//plugin files
    		char strplugfiles[100];

		//dir handle
    		DIR *dirHandle;
    		struct dirent * dirEntry;

    		dirHandle = opendir(&quot;.&quot;);
    		if (dirHandle) 
		{
      		while (0 != (dirEntry = readdir(dirHandle))) 
			{
				//don't show . and ..
				if(strcmp(dirEntry-&gt;d_name, &quot;.&quot;) == 0 || strcmp(dirEntry-&gt;d_name, &quot;..&quot;) == 0)
				{
					continue;
				}
         	 	//cout &lt;&lt; dirEntry-&gt;d_name &lt;&lt; endl;
         	 	stringstream strstrTemp1; 
         	 	strstrTemp1 &lt;&lt; dirEntry-&gt;d_name;
			strplugfiles[ipcount] &lt;&lt; strstrTemp1;
			cout &lt;&lt; strplugfiles[ipcount] &lt;&lt; endl;

         	 	ipcount++;
       		}
       	closedir(dirHandle);
    	}			

	}
</code></pre>
<p>Ich versuche verzweifelt die Ausgabe von dirEentry in den Array (strplugfiles) zu schreiben. Irgendwie habe ich es mit den Datentypen und ihren Eigenarten noch nicht so ganz.</p>
<p>Danke für Eure Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1170012</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1170012</guid><dc:creator><![CDATA[analyzer]]></dc:creator><pubDate>Mon, 06 Nov 2006 20:13:33 GMT</pubDate></item><item><title><![CDATA[Reply to stringstreams + arrays Problem on Mon, 06 Nov 2006 21:36:18 GMT]]></title><description><![CDATA[<p>Du möchtest wahrscheinlich die Filenamen innerhalb eines Directories abspeichern. So weit ich das sehe enthält die Struktur dirent::d_name den jeweiligen Namen.</p>
<p>Dann würde ich Dir empfehlen, die Namen in string's zu speichern. Das Array 'strplugfiles' ist lediglich ein Array von (einzelnen!) Zeichen (Typ char). Dies eignet sich dafür nicht!<br />
Damit Du Dich nicht mit der 100 und dem Index 'ipcount' herumschlagen musst, nehme besser einen vector. Alles zusammen:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;dirent.h&gt;
#include &lt;sstream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;

using namespace std;

int main(int argc, char *argv[])
{
    vector&lt; string &gt; plugfiles; // ein Speicher für strings
    //dir handle
    DIR *dirHandle;
    struct dirent * dirEntry;

    dirHandle = opendir(&quot;.&quot;);
    if (dirHandle)
    {
        while (0 != (dirEntry = readdir(dirHandle)))
        {
            if(strcmp(dirEntry-&gt;d_name, &quot;.&quot;) == 0 || strcmp(dirEntry-&gt;d_name, &quot;..&quot;) == 0)
            {
                continue;
            }
            stringstream strstrTemp1;
            strstrTemp1 &lt;&lt; dirEntry-&gt;d_name;
            plugfiles.push_back( strstrTemp1.str() );
            cout &lt;&lt; plugfiles.back() &lt;&lt; endl; // letzten Eintrag ausgeben
        }
        closedir(dirHandle);
    }           
    return 0;
}
</code></pre>
<p>statt</p>
<pre><code class="language-cpp">stringstream strstrTemp1;
            strstrTemp1 &lt;&lt; dirEntry-&gt;d_name;
            plugfiles.push_back( strstrTemp1.str() );
</code></pre>
<p>geht wahrscheinlich auch</p>
<pre><code class="language-cpp">plugfiles.push_back( string( dirEntry-&gt;d_name ) );
</code></pre>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1170081</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1170081</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Mon, 06 Nov 2006 21:36:18 GMT</pubDate></item><item><title><![CDATA[Reply to stringstreams + arrays Problem on Tue, 07 Nov 2006 18:37:19 GMT]]></title><description><![CDATA[<p>Danke für Deine Antwort. Habs soeben ausprobiert und funktioniert hervorragend. Dass es in C++ Vektoren gibt habe ich noch nie gehört.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1170676</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1170676</guid><dc:creator><![CDATA[analyzer]]></dc:creator><pubDate>Tue, 07 Nov 2006 18:37:19 GMT</pubDate></item></channel></rss>