A primitive folder listing implementation on Windows I am a recent graduate in computer programming and failed so far to get an internship or a job in the business so I am trying my best to learn from online source. 
I am trying to implement a dir-like command on Windows, going through a folder and list all files and folder.

What I've learned is to avoid using namespace std; and making the includes in alphabetical orders.

In this code, I am obviously mixing c and c++, good or bad?
I am also using Digital Mars as a compiler, I'm trying to avoid installing heavy IDEs and compilers like VS.

All thoughts and critiques are welcome.

#include &lt;iostream&gt;
#include &lt;io.h&gt;
#include &lt;string&gt;
#include &lt;sys/stat.h&gt;
#include &lt;sys/types.h&gt;
#include &lt;windows.h&gt;

bool DirectoryExists( const char* absolutePath ){

if( _access( absolutePath, 0 ) == 0 ){

    struct stat status;
    stat( absolutePath, &amp;status );

    return (status.st_mode &amp; S_IFDIR) != 0;
}
return false;
}

char* replace(const char *s){

char* p = new char[strlen(s)+1];
int i=0;

for (i=0;s[i];i++)  
if (s[i]=='\\') 
    p[i] ='/';
else
    p[i]=s[i];

if (p[i-1] == '/')
    p[i]='\0';
else
{   
    p[i]='/';
    p[i+1]='\0';
}

return p;
}

void dirc (const char* destpath){

HANDLE hFind;
WIN32_FIND_DATA FindFileData;
char filename[256];
size_t i=1;

 if((hFind = FindFirstFile(destpath, &amp;FindFileData)) != INVALID_HANDLE_VALUE)
 {
  do    {
        sprintf (filename, "echo %d-%s", i, FindFileData.cFileName);
        system (filename);
        i++;
        }
while(FindNextFile(hFind, &amp;FindFileData));

FindClose(hFind);
}
}

int main(int argc, char**argv) {

const char* path = argv[1];
char* fspath;

if (argv[1] == NULL)
    {
    std::cout &lt;&lt;"No path provided"&lt;&lt;std::endl;
    return 0;
    }

else
    if ( DirectoryExists(path) )
        std::cout &lt;&lt;"Provided path is "&lt;&lt;path&lt;&lt;std::endl;
    else
        {
        std::cout &lt;&lt;"Path doesn't exist"&lt;&lt;std::endl;
        return 0;
        }
 fspath = replace(path);
 char* destpath = (char *) malloc (strlen(fspath)+6);
 destpath = strcat (fspath,"*.*");
 dirc (destpath);
 free (destpath);

return 0;
}
Thous shalt not mix C/C++ unless you have a good reason to do so. Jokes aside, using pure C++ will lead more bug-free code (in terms of memory management etc.) especially since your statement


  What I've learned is to avoid using namespace std; and making the includes in alphabetical orders.


implies (to me) you are a newcomer. You're welcome, by the way. That being said, learning C way of doing things is really helpful, especially if you are not familiar with pointers etc. You will experience first hand, say why C++ smart pointers and containers are a thing.

My advice would be to study exactly why 


  You should not mix C/C++ unless you have a good reason to do so.


What you are doing with this code is nothing but plain C (except iostream methods). I did not check your code thoroughly though. So why do you want to use C++? If you want to use C++, why do you write C code and compile as C++ (again, except iostream, which can be as well stdio.h)?

Since you are using Digital Mars, for which I can't find any standard compliance information, I am not sure if you can use C++17 STL. If you can, there is a filesystem library which can be used to do what you are trying to accomplish with a few lines of code. If you can't, you can try to find a more up-to-date compiler.