title: printf changing value of char*
body: <p>This is the part of my code where this is happening... whatever I am printing with the help of printf its output is repeating 3 times and that value is getting in path variable    </p>
  
  <pre><code>char *path;
      char buf[1024];
      struct group grp;
      struct group *grpt;
      path=strdup(pointer);
      while((sd=readdir(dp))!=NULL)
      {   if(sd-&gt;d_name[0]=='.')
              continue;
          strcat(path,"/");
          strcat(path,sd-&gt;d_name);
          stat(path, &amp;my_stat);
          printf("%s  \t ",sd-&gt;d_name);
          printf("\n");
          int x= (int) (strlen(path) - strlen(sd-&gt;d_name));
          path[x-1]='\0';
          path;
      }
  </code></pre>