<?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[Problem !!!]]></title><description><![CDATA[<p>Hallo,<br />
ich sitze hier gerade vor diesem Code und komme nicht weiter :</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

struct test {
  int ar[10];
} test2, test1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

int a;
int i = 0;
int b;

void test( struct test&amp; p );

int main(void){
  test( test1 );

}

void test( struct test&amp; p){
for(a=0; a&lt;10; a=a+1){
  p.ar[i]=test2.ar[i];
  i=i+1;
}
i=0;
for(b=0; b&lt;10; b=b+1){
  cout &lt;&lt; p.ar[i] &lt;&lt; '\n';
  i=i+1;
}
}
</code></pre>
<p>GCC spukt folgendes aus :</p>
<p>new.cpp:6:48: warning: missing braces around initializer for ‘int [10]’<br />
/tmp/cctoNmQW.o: In function <code>test(test&amp;)': new.cpp:(.text+0xa3): undefined reference to</code>std::cout'<br />
new.cpp:(.text+0xa8): undefined reference to <code>std::basic\_ostream&lt;char, std::char\_traits&lt;char&gt; &gt;::operator&lt;&lt;(int)' new.cpp:(.text+0xb5): undefined reference to</code>std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp; std::operator&lt;&lt; &lt;std::char_traits&lt;char&gt; &gt;(std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;, char)'<br />
/tmp/cctoNmQW.o: In function <code>\_\_static\_initialization\_and\_destruction_0(int, int)': new.cpp:(.text+0x10c): undefined reference to</code>std::ios_base::Init::Init()'<br />
new.cpp:(.text+0x111): undefined reference to `std::ios_base::Init::~Init()'<br />
collect2: ld returned 1 exit status</p>
<p>Kann mir vielleicht jemand helfen? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/293883/problem</link><generator>RSS for Node</generator><lastBuildDate>Sun, 16 Aug 2026 02:55:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/293883.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 12 Oct 2011 17:54:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem !!! on Wed, 12 Oct 2011 17:54:05 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich sitze hier gerade vor diesem Code und komme nicht weiter :</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

struct test {
  int ar[10];
} test2, test1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

int a;
int i = 0;
int b;

void test( struct test&amp; p );

int main(void){
  test( test1 );

}

void test( struct test&amp; p){
for(a=0; a&lt;10; a=a+1){
  p.ar[i]=test2.ar[i];
  i=i+1;
}
i=0;
for(b=0; b&lt;10; b=b+1){
  cout &lt;&lt; p.ar[i] &lt;&lt; '\n';
  i=i+1;
}
}
</code></pre>
<p>GCC spukt folgendes aus :</p>
<p>new.cpp:6:48: warning: missing braces around initializer for ‘int [10]’<br />
/tmp/cctoNmQW.o: In function <code>test(test&amp;)': new.cpp:(.text+0xa3): undefined reference to</code>std::cout'<br />
new.cpp:(.text+0xa8): undefined reference to <code>std::basic\_ostream&lt;char, std::char\_traits&lt;char&gt; &gt;::operator&lt;&lt;(int)' new.cpp:(.text+0xb5): undefined reference to</code>std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp; std::operator&lt;&lt; &lt;std::char_traits&lt;char&gt; &gt;(std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;, char)'<br />
/tmp/cctoNmQW.o: In function <code>\_\_static\_initialization\_and\_destruction_0(int, int)': new.cpp:(.text+0x10c): undefined reference to</code>std::ios_base::Init::Init()'<br />
new.cpp:(.text+0x111): undefined reference to `std::ios_base::Init::~Init()'<br />
collect2: ld returned 1 exit status</p>
<p>Kann mir vielleicht jemand helfen? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2130639</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2130639</guid><dc:creator><![CDATA[the next one]]></dc:creator><pubDate>Wed, 12 Oct 2011 17:54:05 GMT</pubDate></item><item><title><![CDATA[Reply to Problem !!! on Wed, 12 Oct 2011 17:59:19 GMT]]></title><description><![CDATA[<p>Kann's sein, dass du den &quot;gcc&quot; und nicht dessen C++-Frontend &quot;g++&quot; benutzt hast? gcc erkennt zwar an der Dateiendung die Sprache und kann's daher compilieren, aber im anschließenden Linkvorgang wird die C++-Standardbibliothek nicht dazu gelinkt. Das kann man zwar auch von Hand machen, aber einfacher ist es, von vornherein g++ zu benutzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2130644</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2130644</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 12 Oct 2011 17:59:19 GMT</pubDate></item><item><title><![CDATA[Reply to Problem !!! on Wed, 12 Oct 2011 18:10:54 GMT]]></title><description><![CDATA[<p>So ein sch*** Fehler ...<br />
Ja jetzt klappt es.<br />
Danke <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2130650</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2130650</guid><dc:creator><![CDATA[the next one]]></dc:creator><pubDate>Wed, 12 Oct 2011 18:10:54 GMT</pubDate></item><item><title><![CDATA[Reply to Problem !!! on Wed, 12 Oct 2011 18:20:43 GMT]]></title><description><![CDATA[<p>Ein paar Kleinigkeiten:<br />
- Halte deine Variablen möglichst lokal. Das ist in deinem Code nicht gegeben. Es gibt keinen Grund die Variablen a, b, und i global zu halten.<br />
- In der ersten for-Schleife ist das i überflüssig. Dafür kannst du genauso a nehmen.<br />
- Üblicherweise schreibt man in C**++** nicht <code>a = a + 1;</code> sondern <code>a++;</code><br />
- Dem Array des p-Konstruktes weist du Werte von <code>test2</code> zu, die es nicht gibt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2130653</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2130653</guid><dc:creator><![CDATA[*Rewind*]]></dc:creator><pubDate>Wed, 12 Oct 2011 18:20:43 GMT</pubDate></item><item><title><![CDATA[Reply to Problem !!! on Wed, 12 Oct 2011 18:26:41 GMT]]></title><description><![CDATA[<p>[Rewind] schrieb:</p>
<blockquote>
<p>- Üblicherweise schreibt man in C**++** nicht <code>a = a + 1;</code> sondern <code>a++;</code></p>
</blockquote>
<p>Wenn schon dann ++a.<br />
a++ ist nur was für Anfänger.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2130656</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2130656</guid><dc:creator><![CDATA[pedant_for_fun]]></dc:creator><pubDate>Wed, 12 Oct 2011 18:26:41 GMT</pubDate></item><item><title><![CDATA[Reply to Problem !!! on Wed, 12 Oct 2011 21:58:36 GMT]]></title><description><![CDATA[<p>Ja, beim erhöhen des Werts um 1 - sonst sollte sich der &quot;nächste&quot; mal mit += vertraut machen.<br />
<img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f576.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--sunglasses"
      title=":sunglasses:"
      alt="🕶"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2130742</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2130742</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 12 Oct 2011 21:58:36 GMT</pubDate></item><item><title><![CDATA[Reply to Problem !!! on Thu, 13 Oct 2011 18:54:54 GMT]]></title><description><![CDATA[<p>pedant_for_fun schrieb:</p>
<blockquote>
<p>[Rewind] schrieb:</p>
<blockquote>
<p>- Üblicherweise schreibt man in C**++** nicht <code>a = a + 1;</code> sondern <code>a++;</code></p>
</blockquote>
<p>Wenn schon dann ++a.<br />
a++ ist nur was für Anfänger.</p>
</blockquote>
<p>Ach ja ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2131100</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2131100</guid><dc:creator><![CDATA[cvcv]]></dc:creator><pubDate>Thu, 13 Oct 2011 18:54:54 GMT</pubDate></item><item><title><![CDATA[Reply to Problem !!! on Thu, 13 Oct 2011 18:58:23 GMT]]></title><description><![CDATA[<p>*HUST* bitte nicht von Thema ablenken *HUST*</p>
<p>duck und weg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2131101</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2131101</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 13 Oct 2011 18:58:23 GMT</pubDate></item><item><title><![CDATA[Reply to Problem !!! on Thu, 13 Oct 2011 19:49:03 GMT]]></title><description><![CDATA[<p>pedant_for_fun schrieb:</p>
<blockquote>
<p>Wenn schon dann ++a.<br />
a++ ist nur was für Anfänger.</p>
</blockquote>
<p>Eher genau umgekehrt: deine starre Sichtweise ist nur was für Anfänger.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2131131</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2131131</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Thu, 13 Oct 2011 19:49:03 GMT</pubDate></item><item><title><![CDATA[Reply to Problem !!! on Thu, 13 Oct 2011 19:54:18 GMT]]></title><description><![CDATA[<p>Oder wohl eher die <strong>eines</strong> Anfängers.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2131136</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2131136</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 13 Oct 2011 19:54:18 GMT</pubDate></item><item><title><![CDATA[Reply to Problem !!! on Thu, 13 Oct 2011 20:02:35 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p>pedant_for_fun schrieb:</p>
<blockquote>
<p>Wenn schon dann ++a.<br />
a++ ist nur was für Anfänger.</p>
</blockquote>
<p>Eher genau umgekehrt: deine starre Sichtweise ist nur was für Anfänger.</p>
</blockquote>
<p>Dont feed the troll.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2131139</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2131139</guid><dc:creator><![CDATA[*Rewind*]]></dc:creator><pubDate>Thu, 13 Oct 2011 20:02:35 GMT</pubDate></item><item><title><![CDATA[Reply to Problem !!! on Thu, 13 Oct 2011 20:04:38 GMT]]></title><description><![CDATA[<p>pedant_for_fun hat aber schon Recht. Auch wenn es bei <code>int</code> keine Rolle spielen mag, würde ich mir die Präfix-Version angewöhnen, es sei denn man braucht die Semantik der Postfix-Version.</p>
<p>Und Hacker, kannst du mit dem Spam aufhören?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2131140</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2131140</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Thu, 13 Oct 2011 20:04:38 GMT</pubDate></item><item><title><![CDATA[Reply to Problem !!! on Fri, 14 Oct 2011 07:39:35 GMT]]></title><description><![CDATA[<p>Nexus schrieb:</p>
<blockquote>
<p>pedant_for_fun hat aber schon Recht. Auch wenn es bei <code>int</code> keine Rolle spielen mag, würde ich mir die Präfix-Version angewöhnen, es sei denn man braucht die Semantik der Postfix-Version.</p>
<p>Und Hacker, kannst du mit dem Spam aufhören?</p>
</blockquote>
<p>Ah, ja. Sry. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2131146</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2131146</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Fri, 14 Oct 2011 07:39:35 GMT</pubDate></item><item><title><![CDATA[Reply to Problem !!! on Thu, 13 Oct 2011 21:09:46 GMT]]></title><description><![CDATA[<p>Nexus schrieb:</p>
<blockquote>
<p>pedant_for_fun hat aber schon Recht. Auch wenn es bei <code>int</code> keine Rolle spielen mag, würde ich mir die Präfix-Version angewöhnen, es sei denn man braucht die Semantik der Postfix-Version.</p>
<p>Und Hacker, kannst du mit dem Spam aufhören?</p>
</blockquote>
<p>Wieso denn ? Einschübe und andere, gewichtige Stil-Sachen sind verständlich, aber ob ++i oder i++ ... das juckt doch niemanden. Situationsabhängig benutzen und ansonsten nach Vorlieben, würde ich sagen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2131177</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2131177</guid><dc:creator><![CDATA[cvcv]]></dc:creator><pubDate>Thu, 13 Oct 2011 21:09:46 GMT</pubDate></item><item><title><![CDATA[Reply to Problem !!! on Thu, 13 Oct 2011 21:18:15 GMT]]></title><description><![CDATA[<p>Ich empfehle, generell ++i zu bevorzugen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2131181</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2131181</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 13 Oct 2011 21:18:15 GMT</pubDate></item><item><title><![CDATA[Reply to Problem !!! on Thu, 13 Oct 2011 21:39:26 GMT]]></title><description><![CDATA[<p>Wieso denn ? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":/"
      alt="😕"
    /></p>
<p>foo();<br />
i++;<br />
foo();</p>
<p>foo();<br />
++i;<br />
foo();</p>
<p>Soll der operator am zeilenanfang nun schöner sein, oder wie ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2131185</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2131185</guid><dc:creator><![CDATA[cvcv]]></dc:creator><pubDate>Thu, 13 Oct 2011 21:39:26 GMT</pubDate></item><item><title><![CDATA[Reply to Problem !!! on Thu, 13 Oct 2011 21:43:45 GMT]]></title><description><![CDATA[<p>cvcv schrieb:</p>
<blockquote>
<p>Wieso denn ? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":/"
      alt="😕"
    /></p>
<p>foo();<br />
i++;<br />
foo();</p>
<p>foo();<br />
++i;<br />
foo();</p>
<p>Soll der operator am zeilenanfang nun schöner sein, oder wie ?</p>
</blockquote>
<p>Hier kenne ich den Typ von i nicht udn muß annehmen, daß ++i performanter als i++ ist, weil ++i nur eine Referenz auf das erhöhte Objekt zurückgeben muß, während i++ eine Kopie des alten Wertes herauskopieren muß und sich zwischendurch merken muß.</p>
<p>Weil ich nicht nachdenken will, ob i gerade ein einegbauter Typ ist oder eine Langzahlklasse oder ein stl-Iterator oder ein anderer (nicht billig zu kopierender) Iterator, schreibe ich einfach immer ++i. Außer, ich will echt den Rückgabewert von i++ benutzen, um eine lokale Variable zu sparen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2131187</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2131187</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 13 Oct 2011 21:43:45 GMT</pubDate></item><item><title><![CDATA[Reply to Problem !!! on Thu, 13 Oct 2011 21:47:34 GMT]]></title><description><![CDATA[<p>Auch wenn mein Vorschlag die mit dem Postfix verbundene Problematik der Zwischenschritte und des temporären Objekts nicht explizit berücksichtigt, beschränkt er sich nicht auf den Postfix, sondern verweist generell auf die Schreibweise.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2131190</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2131190</guid><dc:creator><![CDATA[*Rewind*]]></dc:creator><pubDate>Thu, 13 Oct 2011 21:47:34 GMT</pubDate></item><item><title><![CDATA[Reply to Problem !!! on Thu, 13 Oct 2011 21:48:15 GMT]]></title><description><![CDATA[<p>Ja gut, wie du selber schon andeutest ist das bei eingebauten typen wayne, kein Geschwindigkeitsverlust.<br />
Bei eigenen typen ist das was anderes.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2131192</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2131192</guid><dc:creator><![CDATA[cvcv]]></dc:creator><pubDate>Thu, 13 Oct 2011 21:48:15 GMT</pubDate></item><item><title><![CDATA[Reply to Problem !!! on Thu, 13 Oct 2011 22:02:57 GMT]]></title><description><![CDATA[<p>cvcv schrieb:</p>
<blockquote>
<p>Ja gut, wie du selber schon andeutest ist das bei eingebauten typen wayne, kein Geschwindigkeitsverlust.<br />
Bei eigenen typen ist das was anderes.</p>
</blockquote>
<p>Du kannst auch konsistent sein und immer <code>++i</code> verwenden, wenn es dir nur auf den Seiteneffekt ankommt. So musst du keine Fälle unterscheiden und bist auf der sicheren Seite.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2131194</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2131194</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Thu, 13 Oct 2011 22:02:57 GMT</pubDate></item></channel></rss>