title: Char pointer results in bad output
body: <p>i have a problem regarding the output of char ptr. following is the sample code which i am trying to execute..</p>
  
  <pre><code>struct DeviceInfo{
  
  char * name;
  int id;
  
  };
  void testFunc(DeviceInfo *info){
  
      char temp[50] = "test input";
      info-&gt;name = temp;
  
  }
  void main(){
  
      DeviceInfo deviceInfo;
      testFunc(&amp;deviceInfo);
      std::cout&lt;&lt;"Output is "&lt;&lt;deviceInfo.name;
  
  
  }
  </code></pre>
  
  <p>Output i get in the main is some kind of weird one ....
  while debugging i find out that when "test.name" is passed on to output stream it not only
  gives garbage output but it also changes the "name" value for "deviceInfo" object to that garbage value... 
  this is kind of test scenario but in actual application this testFunc has to be executed in the same way i.e. constant char string should be assigned name to char ptr.</p>
  
  <p>i tried puting '\0' at the end of char temp like this temp[strlen(temp)] = '\0';</p>
  
  <p>but it still dont work</p>
  
  <p>Any help is appreciated...</p>
  
  <p>Raza</p>