<?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[call by value mit char]]></title><description><![CDATA[<p>Hi leute ich will einer Funktion call bei value einen char array übergeben!<br />
ich glaub das übergeben funktioniert einigermasen aber wenn ich dann denn wert verwenden will bring er mir fehler...<br />
der code:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;cstring&gt;
using namespace std;

void callbyreference(char &amp;test){
     strncpy(test, &quot;xyz&quot;, 3);
     }

main(){
       char c[] = &quot;abc&quot;;
       callbyreference(c);
       cout &lt;&lt; &quot;\n&quot; &lt;&lt; c;
       }
</code></pre>
<p>Die Fehler:<br />
C:\...\callbyreference.cpp In function <code>void callbyreference(char&amp;)': 9 C:\\...\\callbyreference.cpp invalid conversion from \</code>char' to `char*'<br />
9 C:\...\callbyreference.cpp initializing argument 1 of <code>char* strncpy(char*, const char*, size_t)' C:\\...\\callbyreference.cpp In function</code>int main()':<br />
15 C:\...\callbyreference.cpp invalid initialization of non-const reference of type 'char&amp;' from a temporary of type 'char*'<br />
8 C:\...\callbyreference.cpp in passing argument 1 of `void callbyreference(char&amp;)'</p>
<p>Was mach ich da Falsch? denn code hab ich jetzt in dev-cpp compillert(...versucht) mit ms visual c++ 2005 express edition schauts nicht viel anders aus...<br />
Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/191142/call-by-value-mit-char</link><generator>RSS for Node</generator><lastBuildDate>Fri, 25 Sep 2026 22:15:54 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/191142.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 30 Aug 2007 16:12:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to call by value mit char on Thu, 30 Aug 2007 16:12:13 GMT]]></title><description><![CDATA[<p>Hi leute ich will einer Funktion call bei value einen char array übergeben!<br />
ich glaub das übergeben funktioniert einigermasen aber wenn ich dann denn wert verwenden will bring er mir fehler...<br />
der code:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;cstring&gt;
using namespace std;

void callbyreference(char &amp;test){
     strncpy(test, &quot;xyz&quot;, 3);
     }

main(){
       char c[] = &quot;abc&quot;;
       callbyreference(c);
       cout &lt;&lt; &quot;\n&quot; &lt;&lt; c;
       }
</code></pre>
<p>Die Fehler:<br />
C:\...\callbyreference.cpp In function <code>void callbyreference(char&amp;)': 9 C:\\...\\callbyreference.cpp invalid conversion from \</code>char' to `char*'<br />
9 C:\...\callbyreference.cpp initializing argument 1 of <code>char* strncpy(char*, const char*, size_t)' C:\\...\\callbyreference.cpp In function</code>int main()':<br />
15 C:\...\callbyreference.cpp invalid initialization of non-const reference of type 'char&amp;' from a temporary of type 'char*'<br />
8 C:\...\callbyreference.cpp in passing argument 1 of `void callbyreference(char&amp;)'</p>
<p>Was mach ich da Falsch? denn code hab ich jetzt in dev-cpp compillert(...versucht) mit ms visual c++ 2005 express edition schauts nicht viel anders aus...<br />
Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1355492</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1355492</guid><dc:creator><![CDATA[a293]]></dc:creator><pubDate>Thu, 30 Aug 2007 16:12:13 GMT</pubDate></item><item><title><![CDATA[Reply to call by value mit char on Thu, 30 Aug 2007 16:19:14 GMT]]></title><description><![CDATA[<p>char&amp; ist eine Referenz auf char. char[] ist ein Array von chars und kann in ein char*, also einen Zeiger auf char, aber nicht in char&amp; umgewandelt werden. Das sagt dir dein Compiler. Nun such dir dein Buch heraus, und schau, was das bedeutet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1355498</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1355498</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Thu, 30 Aug 2007 16:19:14 GMT</pubDate></item><item><title><![CDATA[Reply to call by value mit char on Thu, 30 Aug 2007 16:20:20 GMT]]></title><description><![CDATA[<p>mach draus:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;cstring&gt;
using namespace std;

void callbyreference(char &amp;test)
{
     strncpy(&amp;test, &quot;xyz&quot;, 3);
}

main()
{
       char c[] = &quot;abc&quot;;
       callbyreference(*c);
       cout &lt;&lt; &quot;\n&quot; &lt;&lt; c;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1355499</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1355499</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Thu, 30 Aug 2007 16:20:20 GMT</pubDate></item><item><title><![CDATA[Reply to call by value mit char on Thu, 30 Aug 2007 16:22:12 GMT]]></title><description><![CDATA[<p>a293 schrieb:</p>
<blockquote>
<p>Hi leute ich will einer Funktion call bei value einen char array übergeben!</p>
</blockquote>
<p>Das ist nicht möglich. Eine Einschränkung, die von C geerbt wurde. Ein Array kann niemals der Typ eines Parameters oder Rückgabewertes einer Funktion sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1355502</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1355502</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Thu, 30 Aug 2007 16:22:12 GMT</pubDate></item><item><title><![CDATA[Reply to call by value mit char on Thu, 30 Aug 2007 16:53:32 GMT]]></title><description><![CDATA[<p>lässt sich aber ganz leicht ein Workaround basteln <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<pre><code class="language-cpp">struct TBlah {
  int arr[10];
  TBlah(TBlah &amp;cp) {
    for(int i=0;i&lt;10;++i)
     arr[i] = cp.arr[i];
  }
};

TBlah Funktion_Die_Ein_Array_Als_Parameter_Hat_Und_Zurück_gibt(TBlah param) {
  return param;
}
</code></pre>
<p>(die Funktion ist völlig sinnlos, falls einer den Sinn suchen sollte)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1355512</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1355512</guid><dc:creator><![CDATA[Checker*amp*Murckser]]></dc:creator><pubDate>Thu, 30 Aug 2007 16:53:32 GMT</pubDate></item><item><title><![CDATA[Reply to call by value mit char on Thu, 30 Aug 2007 16:45:33 GMT]]></title><description><![CDATA[<pre><code>Funktion_Die_Ein_Array_Als_Parameter_Hat_Und_Zurück_gibt
</code></pre>
<p>du sollst nicht lügen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1355515</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1355515</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Thu, 30 Aug 2007 16:45:33 GMT</pubDate></item><item><title><![CDATA[Reply to call by value mit char on Thu, 30 Aug 2007 16:54:16 GMT]]></title><description><![CDATA[<p>camper schrieb:</p>
<blockquote>
<pre><code>Funktion_Die_Ein_Array_Als_Parameter_Hat_Und_Zurück_gibt
</code></pre>
<p>du sollst nicht lügen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
</blockquote>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> zumindest tut sie das, was der User will (oder auch nicht will)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1355518</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1355518</guid><dc:creator><![CDATA[Checker*amp*Murckser]]></dc:creator><pubDate>Thu, 30 Aug 2007 16:54:16 GMT</pubDate></item></channel></rss>