title: i click the Back Button, the Program can get the normal path, but when i click the Back Button again, it happens error. i don't know if memory problem
body: <p>i click the Back Button, the Program can get the normal path, but when i click the Back Button again, it happens error. i don't know if memory problem. I omit the code to create the window, I can issue it if necessary. Maybe I am a beginner, the code is not very concise, please suggest if there are suggestions for improvement.</p>
  <pre><code>HWND BackButton;
  std::string strFilePath = &quot;C:\\Program Files (x86)\\360\\360DrvMgr\\config\\defaultskin\\*.*&quot;;  /* Initial path */
  LPCSTR FilePath = strFilePath.c_str(); /* exchange to LPCSTR */
  </code></pre>
  <p>{</p>
  <pre><code>switch (message)
          {
          case WM_CREATE:
          {
              BackButton = CreateWindow(WC_BUTTON, &quot;BACK&quot;, WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 850, 235, 30, 30, hwnd, HMENU(BACK), AppInstance, NULL);  /*Create the BACK Button*/
          }
          break;
  
      case WM_COMMAND:
      {
          switch (LOWORD(wParam)) /* mouse event*/
          {
  
          case BACK: /* clik the BACK button*/
          {
              const char *pc = FilePath; /*Initial path*/
              char drive[_MAX_DRIVE];    /*_splitpath_s param*/
              char dir[_MAX_DIR];        /*_splitpath_s param*/
              char fname[_MAX_FNAME];    /*_splitpath_s param*/
              char ext[_MAX_EXT];
              char split[] = &quot;\\&quot;;       /*_splitpath_s param*/
              char *p = NULL;            /*filter*/;
              int countSlantBar = 0;  
              std::string ReMakePath;   /* string fathe dir name*/
              std::string MakePath;     /* final full path */
  
              _splitpath_s(pc, drive, dir, fname, ext);
              int Sdir = strlen(dir);
              for (Sdir - 3; Sdir &gt;= 0; Sdir--) /* when click the BACK button get the father dir name*/
              {   
                  if (pc[Sdir] == *split)
                  {
                      ReMakePath = ReMakePath + pc[Sdir];
                  }
                  if (countSlantBar == 1) {
                      break;
                  }
                  else
                  {
                      ReMakePath = pc[Sdir] + ReMakePath;   /* save the fathe dir as string */
                  }
              }
              std::string s = pc;
              int pos = s.find(ReMakePath);
              int n = ReMakePath.size();
              s = s.erase(pos, n);    /* cut the father dir name\\ and save *.* */
              LPCSTR Mpath = s.c_str();   
              SendMessage(ComBox, CB_ADDSTRING, 0, LPARAM(Mpath));
              FilePath = Mpath;  /* The location of the error */                                                   
              break;
          }
          return TRUE;
          } 
          break;
  </code></pre>
  <p><a href="https://i.stack.imgur.com/YdCtP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YdCtP.png" alt="enter image description here" /></a></p>