<?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[struct array + string + ausgabe mit printf]]></title><description><![CDATA[<p>Hallo ich habe ein struct in einem Header:</p>
<pre><code class="language-cpp">struct Karteikarte
{
	string Vorname;
	string Straße;
	string SNummer;
	string  Stadt;
};
</code></pre>
<p>dann erstelle ich ein Feld mit 20 Karteikarten</p>
<pre><code class="language-cpp">Karteikarte feld[20];
</code></pre>
<p>dann tu ich das initialisieren mit irgend welchen Werten</p>
<pre><code class="language-cpp">for(int i=0; i&lt;20; i++)
	{
		feld[i].Vorname = &quot;Dieter&quot;;
		feld[i].Straße = &quot;Feldweg 3&quot;;
		feld[i].Stadt = &quot;Erfurt&quot;;
		//feld[i].SNummer = (char) i;
	}
</code></pre>
<p>bis dahin geht alles und jetzt kommt das problem ch will das ganze testweise ausgeben</p>
<pre><code class="language-cpp">for(int i=0; i&lt;20; i++)
	{
	printf(&quot;%s wohnt in der/im/am %s in %s und hat die Schornsteinnummer \
			   \n&quot;, feld[i].Vorname, feld[i].Straße, feld[i].Stadt);
	}
</code></pre>
<p>ja und bei der ausgabe kommt dann :</p>
<pre><code>Unbehandelte Ausnahme bei 0x10227c2f (msvcr80d.dll) in Uebung_8.exe: 0xC0000005: Zugriffsverletzung beim Lesen an Position 0x74656944.
</code></pre>
<p>an der stelle in der outpu.c :</p>
<pre><code>#else  /* _UNICODE */
                if (flags &amp; (FL_LONG|FL_WIDECHAR)) {
                    if (text.wz == NULL) /* NULL passed, use special string */
                        text.wz = __wnullstring;
                    bufferiswide = 1;
                    pwch = text.wz;
                    while ( i-- &amp;&amp; *pwch )
                        ++pwch;
                    textlen = (int)(pwch - text.wz);
                    /* textlen now contains length in wide chars */
                } else {
                    if (text.sz == NULL) /* NULL passed, use special string */
                        text.sz = __nullstring;
                    p = text.sz;
      ---&gt;            while (i-- &amp;&amp; *p)
                        ++p;
                    textlen = (int)(p - text.sz);    /* length of the string */
                }
</code></pre>
<p>ich denk mal ich muss das anders ausgeben aber ich hab noch kein plan wie. Wer kann mir da helfen? Wenn ja wie?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/167379/struct-array-string-ausgabe-mit-printf</link><generator>RSS for Node</generator><lastBuildDate>Tue, 15 Sep 2026 23:42:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/167379.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 10 Dec 2006 15:52:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to struct array + string + ausgabe mit printf on Sun, 10 Dec 2006 15:52:28 GMT]]></title><description><![CDATA[<p>Hallo ich habe ein struct in einem Header:</p>
<pre><code class="language-cpp">struct Karteikarte
{
	string Vorname;
	string Straße;
	string SNummer;
	string  Stadt;
};
</code></pre>
<p>dann erstelle ich ein Feld mit 20 Karteikarten</p>
<pre><code class="language-cpp">Karteikarte feld[20];
</code></pre>
<p>dann tu ich das initialisieren mit irgend welchen Werten</p>
<pre><code class="language-cpp">for(int i=0; i&lt;20; i++)
	{
		feld[i].Vorname = &quot;Dieter&quot;;
		feld[i].Straße = &quot;Feldweg 3&quot;;
		feld[i].Stadt = &quot;Erfurt&quot;;
		//feld[i].SNummer = (char) i;
	}
</code></pre>
<p>bis dahin geht alles und jetzt kommt das problem ch will das ganze testweise ausgeben</p>
<pre><code class="language-cpp">for(int i=0; i&lt;20; i++)
	{
	printf(&quot;%s wohnt in der/im/am %s in %s und hat die Schornsteinnummer \
			   \n&quot;, feld[i].Vorname, feld[i].Straße, feld[i].Stadt);
	}
</code></pre>
<p>ja und bei der ausgabe kommt dann :</p>
<pre><code>Unbehandelte Ausnahme bei 0x10227c2f (msvcr80d.dll) in Uebung_8.exe: 0xC0000005: Zugriffsverletzung beim Lesen an Position 0x74656944.
</code></pre>
<p>an der stelle in der outpu.c :</p>
<pre><code>#else  /* _UNICODE */
                if (flags &amp; (FL_LONG|FL_WIDECHAR)) {
                    if (text.wz == NULL) /* NULL passed, use special string */
                        text.wz = __wnullstring;
                    bufferiswide = 1;
                    pwch = text.wz;
                    while ( i-- &amp;&amp; *pwch )
                        ++pwch;
                    textlen = (int)(pwch - text.wz);
                    /* textlen now contains length in wide chars */
                } else {
                    if (text.sz == NULL) /* NULL passed, use special string */
                        text.sz = __nullstring;
                    p = text.sz;
      ---&gt;            while (i-- &amp;&amp; *p)
                        ++p;
                    textlen = (int)(p - text.sz);    /* length of the string */
                }
</code></pre>
<p>ich denk mal ich muss das anders ausgeben aber ich hab noch kein plan wie. Wer kann mir da helfen? Wenn ja wie?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1189546</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1189546</guid><dc:creator><![CDATA[pad8626]]></dc:creator><pubDate>Sun, 10 Dec 2006 15:52:28 GMT</pubDate></item><item><title><![CDATA[Reply to struct array + string + ausgabe mit printf on Sun, 10 Dec 2006 15:58:56 GMT]]></title><description><![CDATA[<p>printf und std::string passen nicht. Da wirst Du c_str() verwenden müssen um es printf recht zu machen.</p>
<p>Besser wäre aber die Ausgabe mit cout:</p>
<pre><code class="language-cpp">cout&lt;&lt;feld[i].Vorname &lt;&lt; &quot; wohnt in der/im/am &quot; &lt;&lt; feld[i].Straße &lt;&lt;&quot; in &quot;&lt;&lt; feld[i].Stadt &lt;&lt; &quot; und hat die Schornsteinnummer &quot;&lt;&lt;endl;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1189553</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1189553</guid><dc:creator><![CDATA[Knuddlbaer]]></dc:creator><pubDate>Sun, 10 Dec 2006 15:58:56 GMT</pubDate></item><item><title><![CDATA[Reply to struct array + string + ausgabe mit printf on Sun, 10 Dec 2006 16:58:21 GMT]]></title><description><![CDATA[<p>wie benutz ich dieses c_str()? und was muss ich dafür noch einbinden</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1189610</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1189610</guid><dc:creator><![CDATA[pad8626]]></dc:creator><pubDate>Sun, 10 Dec 2006 16:58:21 GMT</pubDate></item><item><title><![CDATA[Reply to struct array + string + ausgabe mit printf on Sun, 10 Dec 2006 17:19:11 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>c_str() ist eine Methode von std::string. Wenn du also schon std::string verwendest, must du nichts weiter für c_str() einbinden.<br />
Sondern du rufst es für das konkrete String-Objekt auf</p>
<pre><code class="language-cpp">std::string test = &quot;Test&quot;;
func(test.c_str());
</code></pre>
<p>Allerdings solltest du unbedingtwie Knuddelbaer gezeigt hat die ordentlichen C++ Mittel benutzen, statt alter C-Mittel.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1189627</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1189627</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Sun, 10 Dec 2006 17:19:11 GMT</pubDate></item><item><title><![CDATA[Reply to struct array + string + ausgabe mit printf on Sun, 10 Dec 2006 17:21:21 GMT]]></title><description><![CDATA[<p>mir hat mal jemand gesagt das cout net so toll sein soll</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1189630</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1189630</guid><dc:creator><![CDATA[pad8626]]></dc:creator><pubDate>Sun, 10 Dec 2006 17:21:21 GMT</pubDate></item><item><title><![CDATA[Reply to struct array + string + ausgabe mit printf on Sun, 10 Dec 2006 18:06:56 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Dann frag doch mal dem jemand, was an cout &quot;net so toll&quot; sein soll.<br />
Und warum das typunsiche printf benutzten will.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1189660</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1189660</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Sun, 10 Dec 2006 18:06:56 GMT</pubDate></item><item><title><![CDATA[Reply to struct array + string + ausgabe mit printf on Sun, 10 Dec 2006 18:29:02 GMT]]></title><description><![CDATA[<p>pad8626 schrieb:</p>
<blockquote>
<p>mir hat mal jemand gesagt das cout net so toll sein soll</p>
</blockquote>
<p>Ist es auch nicht. Aber immer noch besser als dieses ganze printf Zeugs.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1189682</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1189682</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Sun, 10 Dec 2006 18:29:02 GMT</pubDate></item><item><title><![CDATA[Reply to struct array + string + ausgabe mit printf on Mon, 11 Dec 2006 18:10:43 GMT]]></title><description><![CDATA[<p>wenn beides net toll ist gibts alternativen ??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1190281</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1190281</guid><dc:creator><![CDATA[pad8626]]></dc:creator><pubDate>Mon, 11 Dec 2006 18:10:43 GMT</pubDate></item><item><title><![CDATA[Reply to struct array + string + ausgabe mit printf on Mon, 11 Dec 2006 18:13:15 GMT]]></title><description><![CDATA[<p>Wozu, nutzt einfach cout, das ist ausreichend und noch dazu Typensicher! <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/1190283</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1190283</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Mon, 11 Dec 2006 18:13:15 GMT</pubDate></item><item><title><![CDATA[Reply to struct array + string + ausgabe mit printf on Mon, 11 Dec 2006 18:19:23 GMT]]></title><description><![CDATA[<p>war aber nicht antwort auf meine frage</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1190290</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1190290</guid><dc:creator><![CDATA[pad8626]]></dc:creator><pubDate>Mon, 11 Dec 2006 18:19:23 GMT</pubDate></item></channel></rss>