<?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[Arrays nutzen?]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich muss in meinem neuen Beispielprojekt (bin in der Lernphase) nun<br />
häufiger ini-Werte auslesen.</p>
<p>Bislang habe ich den Code immer neu hinkopiert, das geht aber sicher auch einfacher.<br />
Ich bin mir nur nicht sicher wie.</p>
<p>Das würde ich immer wieder kopieren mit neuen Variablen:</p>
<pre><code class="language-cpp">char *pBuf = new char[300];
    CString returnstring;
    GetPrivateProfileString(&quot;Sektion1&quot;,&quot;1&quot;,&quot;error&quot;,pBuf,300,&quot;c:\\log.ini&quot;);
    returnstring.Format(&quot;%s&quot;,pBuf);
    delete []pBuf;
</code></pre>
<p>Ich dachte an diese Arrays, aber würde es denn so überhaupt Sinn machen?</p>
<pre><code class="language-cpp">char *pBuf = new char[300];
CString returnstring[20];
CString wertzahl[20];

for(int x=0;x&lt;=20;x++)
{
    GetPrivateProfileString(&quot;Sektion1&quot;,wertzahl[x],&quot;error&quot;,pBuf,300,&quot;c:\\log.ini&quot;);
    returnstring[x].Format(&quot;%s&quot;,pBuf);
}
    delete []pBuf;
CString xyz;
xyz=returnstring[10];
MessageBox(xyz,&quot;Wert aus Array&quot;);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/179254/arrays-nutzen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 20:37:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/179254.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 19 Apr 2007 19:04:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Arrays nutzen? on Thu, 19 Apr 2007 19:04:24 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich muss in meinem neuen Beispielprojekt (bin in der Lernphase) nun<br />
häufiger ini-Werte auslesen.</p>
<p>Bislang habe ich den Code immer neu hinkopiert, das geht aber sicher auch einfacher.<br />
Ich bin mir nur nicht sicher wie.</p>
<p>Das würde ich immer wieder kopieren mit neuen Variablen:</p>
<pre><code class="language-cpp">char *pBuf = new char[300];
    CString returnstring;
    GetPrivateProfileString(&quot;Sektion1&quot;,&quot;1&quot;,&quot;error&quot;,pBuf,300,&quot;c:\\log.ini&quot;);
    returnstring.Format(&quot;%s&quot;,pBuf);
    delete []pBuf;
</code></pre>
<p>Ich dachte an diese Arrays, aber würde es denn so überhaupt Sinn machen?</p>
<pre><code class="language-cpp">char *pBuf = new char[300];
CString returnstring[20];
CString wertzahl[20];

for(int x=0;x&lt;=20;x++)
{
    GetPrivateProfileString(&quot;Sektion1&quot;,wertzahl[x],&quot;error&quot;,pBuf,300,&quot;c:\\log.ini&quot;);
    returnstring[x].Format(&quot;%s&quot;,pBuf);
}
    delete []pBuf;
CString xyz;
xyz=returnstring[10];
MessageBox(xyz,&quot;Wert aus Array&quot;);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1269551</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1269551</guid><dc:creator><![CDATA[CalleBlonquist]]></dc:creator><pubDate>Thu, 19 Apr 2007 19:04:24 GMT</pubDate></item><item><title><![CDATA[Reply to Arrays nutzen? on Fri, 20 Apr 2007 07:01:28 GMT]]></title><description><![CDATA[<p>Erstmal: Je nach Anwendung kann das durchaus Sinn machen, allerdings solltest du nicht über das Array-Ende hinausschreiben (oder gleich dynamisch erweiterbare Container verwenden).</p>
<p>Zweitens: Das Gebastel mit dem char* sieht ja übel aus - hol dir doch direkt den richtigen Buffer per GetBuffer():</p>
<pre><code class="language-cpp">CString returnstring;
GetPrivateProfileString(&quot;Sektion1&quot;,&quot;1&quot;,&quot;error&quot;,returnstring.GetBuffer(300),300,&quot;c:\\log.ini&quot;);
returnstring.ReleaseBuffer();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1269745</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1269745</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Fri, 20 Apr 2007 07:01:28 GMT</pubDate></item><item><title><![CDATA[Reply to Arrays nutzen? on Fri, 20 Apr 2007 20:45:18 GMT]]></title><description><![CDATA[<p>Hallo CStoll,</p>
<p>danke für deinen Tipp.</p>
<p>Sag mal wie mache ich das richtig, damit ich den 2ten Parameter variabel<br />
bzw. für ein Array anlege?</p>
<pre><code class="language-cpp">GetPrivateProfileString(&quot;Sektion1&quot;,&quot;Wert1&quot;,&quot;error&quot;,pBuf,300,&quot;c:\\log.ini&quot;);
</code></pre>
<p>Nun soll statt Wert1 laufend hochgezählt werden (&quot;Wert2&quot;,&quot;Wert3&quot; etc.).<br />
Ich fürchte so einfach wie ich es mir vorstellte ist es dann doch nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1270274</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1270274</guid><dc:creator><![CDATA[Calle]]></dc:creator><pubDate>Fri, 20 Apr 2007 20:45:18 GMT</pubDate></item><item><title><![CDATA[Reply to Arrays nutzen? on Fri, 20 Apr 2007 20:56:32 GMT]]></title><description><![CDATA[<p>vom prinzip her etwa so:</p>
<pre><code>for (int i=0; i&lt;10; i++)
{
   CString wert; 
   wert.Format (&quot;Wert%d&quot;, i);
   GetPrivateProfileString(&quot;Sektion1&quot;,wert,&quot;error&quot;,pBuf,300,&quot;c:\\log.ini&quot;);
}
</code></pre>
<p>zählt von 'Wert0' bis 'Wert9'<br />
<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>
]]></description><link>https://www.c-plusplus.net/forum/post/1270280</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1270280</guid><dc:creator><![CDATA[vista]]></dc:creator><pubDate>Fri, 20 Apr 2007 20:56:32 GMT</pubDate></item></channel></rss>