title: passing array as parameter to a function
body: <p>this script is supposed to output array values that were inputted by the user into array "store." I am trying to store all the char array values into string temp. I get the error on line 12: "[Error] invalid conversion from 'char*' to 'char' [-fpermissive]." Would appreciate any help! </p>
  
  <p>Edit: so I fixed the declaration and now at least it compiles, but the answer I get on my cmd is all jumbled up. Why is this so? The cmd only correctly couts the first string but after the space, it messes up.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  
  using namespace std;
  void coutArray(char[], int);
  int main()
  {
      char store[50];
  
      cout &lt;&lt; "enter text: " &lt;&lt; endl;
      cin &gt;&gt; store;
      coutArray(store, 50);
  
      system("pause");
      return 0;
  
  }
  void coutArray(char store[], int max)
  {
      string temp = "";
      int i = 0;
      while (i &lt; max)
      {
          temp += store[i];
          i++; 
      }
      cout &lt;&lt; temp &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Using input from all answerers I finally got the fixed code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;string&gt;
  
  using namespace std;
  void coutArray(char[], int);
  int main()
  {
      char store[50] = {0};
  
      cout &lt;&lt; "enter text: " &lt;&lt; endl;
      cin.getline(store, 50);
      coutArray(store, 50);
  
      system("pause");
      return 0;
  
  }
  void coutArray(char store[], int max)
  {
      string temp = "";
      int i = 0;
      while (i &lt; max &amp;&amp; store[i]!=0)
      {
          temp += store[i];
          i++; 
      }
      cout &lt;&lt; temp &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Thanks everyone.  i learned a lot!!!</p>