First, you can use the "system" command", but it's generally frowned upon. Normally you use "execvp", execlp", or something similar, after forking, piping, or whatever. Use the Microsoft equivalent. The system command is doable, but keep in mind the lifetime of the process and where stdout goes, etc. The system command starts a new process, executes it then closes it. Any changes of directory stops when this process ends. So if you change the directory with a system command, the working directory of your emulator will NOT change. This is in addition to any syntax problems you may have in the program.
I don't know what direct.h or gets_s is. I'm not using Visual Studio, so if it's Visual Studio-specific, I can't compile the program using Code Blocks.
If you want to use the system command, I would suggest keeping track of the current directory in the program itself. When the user enters "cd", change the variable to the argument specified after "cd". Don't invoke the system command when the user enters "cd".
When the user enters "dir", do something like this.
string working_directory; // contains the working directory
string command = "dir " + working_directory;
system(command.c_str());
Now, I don't know if this will display or not. I can't remember how the system command works there. You may need to pipe it. But if "dir" already is working for you now, perhaps not.
But the gist is this. You need to be aware that the process created by the system command will not be the process of your emulator, so a change in the environmental variables (i.e. working directory) in the "system" process will not cause a change in the other process. So I think you need to keep a variable in the emulator process.