<?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[Array aus Funktion in Array übertragen]]></title><description><![CDATA[<p>Titel sagt eigentlich alles.<br />
Die Aufgabe war zwei Arrays mit zwei werten zu initialisieren(sollen Brüche darstellen) und mit einer Funktion zu multiplizieren. Dann das Ergebnis in ein drittes array namens c übergeben.</p>
<p>Bisher siehts bei mir so aus, wo ich Probleme habe ist, das Ergebnis der Funktion in das dritte Array zu übergeben.<br />
Sie wie der Code unten steht gibt er mir eine Fehlermeldung aus.<br />
Error in 12: Lvalue required in function main()<br />
Die Fehlermeldung sagt mir gar nichts.</p>
<p>Wäre schön wenn mir jemand erklären könnte wie man das Ergebnis ins Dritte Array übergibt.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;
int* mul(int *x,int *y)
{ int s[2];
  s[0]=x[0]*y[0];
  s[1]=x[1]*y[1];
return s;
}

int main() 
{ int a[2]={1,2},b[2]={3,4}, c[2];
c=*mul(a,b);
cout&lt;&lt;c[0]&lt;&lt;endl;
cout&lt;&lt;c[1];
getchar();
return 0; 
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/301498/array-aus-funktion-in-array-übertragen</link><generator>RSS for Node</generator><lastBuildDate>Tue, 11 Aug 2026 23:50:34 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/301498.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 28 Mar 2012 17:48:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Array aus Funktion in Array übertragen on Wed, 28 Mar 2012 17:49:35 GMT]]></title><description><![CDATA[<p>Titel sagt eigentlich alles.<br />
Die Aufgabe war zwei Arrays mit zwei werten zu initialisieren(sollen Brüche darstellen) und mit einer Funktion zu multiplizieren. Dann das Ergebnis in ein drittes array namens c übergeben.</p>
<p>Bisher siehts bei mir so aus, wo ich Probleme habe ist, das Ergebnis der Funktion in das dritte Array zu übergeben.<br />
Sie wie der Code unten steht gibt er mir eine Fehlermeldung aus.<br />
Error in 12: Lvalue required in function main()<br />
Die Fehlermeldung sagt mir gar nichts.</p>
<p>Wäre schön wenn mir jemand erklären könnte wie man das Ergebnis ins Dritte Array übergibt.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;
int* mul(int *x,int *y)
{ int s[2];
  s[0]=x[0]*y[0];
  s[1]=x[1]*y[1];
return s;
}

int main() 
{ int a[2]={1,2},b[2]={3,4}, c[2];
c=*mul(a,b);
cout&lt;&lt;c[0]&lt;&lt;endl;
cout&lt;&lt;c[1];
getchar();
return 0; 
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2196335</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2196335</guid><dc:creator><![CDATA[hyperionb]]></dc:creator><pubDate>Wed, 28 Mar 2012 17:49:35 GMT</pubDate></item><item><title><![CDATA[Reply to Array aus Funktion in Array übertragen on Wed, 28 Mar 2012 17:52:38 GMT]]></title><description><![CDATA[<p>Du kannst keine (rohen) Arrays zurückgeben.</p>
<pre><code class="language-cpp">// C-Style:
void mul(int *a, int *b, int *c)
{
  c[0] = a[0] * b[0];
  c[1] = a[1] * b[1];
}

// C++-Style
#include &lt;array&gt;

std::array&lt;int, 2&gt; mul(int *a, int *b)
{
  std::array&lt;int, 2&gt; c;
  c[0] = a[0] * b[0];
  c[1] = a[1] * b[1];
  return c;
}
</code></pre>
<p>Wobei man in C eher eine Struktur &quot;Bruch&quot; nehmen würde, und in C++ eine Klasse &quot;Bruch&quot; mit entsprechend überladenen Operatoren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2196337</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2196337</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Wed, 28 Mar 2012 17:52:38 GMT</pubDate></item></channel></rss>