title: Why my source is changing when using strcpy in c
body: <p>After using strcpy source is getting corrupted and getting correct destination. Following is my code please suggest me why my source is getting corrupted? If i keep a fixed size to second character array q[] then my source is not being changed. Why is this strange behaviour. -<br>
  I am using MSVC 2005</p>
  
  <pre><code>void function(char* str1,char* str2);
  void main()
  {
  
      char p[]="Hello world";
      char q[]="";
      function(p,q);
      cout&lt;&lt;"after function calling..."&lt;&lt;endl;
      cout&lt;&lt;"string1:"&lt;&lt;"\t"&lt;&lt;p&lt;&lt;endl;
      cout&lt;&lt;"string2:"&lt;&lt;"\t"&lt;&lt;q&lt;&lt;endl;
      cin.get();
  }
  
  void function(char* str1, char* str2)
  {
      strcpy(str2,str1);
  }
  </code></pre>
  
  <p>OUTPUT: </p>
  
  <pre><code>after function calling...
  string1:        ld
  string2:        Hello world
  </code></pre>
  
  <p>Thanks in advance,<br>
  Malathi</p>