title: How to pass character array to a function in C++ without any temporary char array as variable?
body: <p>I have the following code</p>
  
  <pre><code>void func(char c[])  {
      c[1]= '@';
      std::cout&lt;&lt;c&lt;&lt;"\n"
               &lt;&lt;sizeof(c)&lt;&lt;"\n";
  }
  
  // Main 1
  int main()  {
      char temp[6] = "pinta";
      func(temp);
  }
  </code></pre>
  
  <p>Here if I change the main function to the following </p>
  
  <pre><code>//Main 2
  int main()
  {
      func("pinta");
  }
  
  meow@vikkyhacks ~/Arena/c/LinkedList $ g++-4.8 scrap/test.cpp 
  scrap/test.cpp: In function ‘int main()’:
  scrap/test.cpp:12:14: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    func("pinta");
                ^
  </code></pre>
  
  <p>After some googling, I learned that the second <code>main</code> is not passing any character array by instead passing a <code>read only string literal</code> which when hits the <code>c[1] = '@'</code> throws a seg fault.</p>
  
  <p>My Question is </p>
  
  <ol>
  <li><p>"<strong><em>How do I avoid the use of the <code>temp</code> variable which is used in
  the <code>Main 1</code> and directly pass a character array to the <code>func</code> as
  its parameter ?</em></strong>"</p></li>
  <li><p>And important condition is to allow the editing of the character
  array passed into the <code>func</code>.</p></li>
  </ol>
  
  <h2>EDIT</h2>
  
  <p>I see there are many answers which prevent me from doing <code>c[1]= '@';</code> , which I cannot do because that line is very important for me.</p>