If you want to write your own mini-dos then you can not use the system() function for anything.
You can get list of files and sub-directories in MS-Windows by using the FindFirstFile() and FindNextFile() win32 api functions (look them up with google to find exact syntax.) You can find all sorts of examples on the net, just use google.
Are you trying to make a shell that will run ontop of windows executing windows/dos programs? Just keep track of your current directory youself in an extra variable. Example:
The current directory variable now holds: c:\myprogram\
(remember to check if it exsists)
Would first check to see if c:\myprogram\main.exe exsisted.
If it did, run system("c:\myprogram\main.exe");
if not, check to see if c:\dos\main.exe exsisted.
If it did, run system("c:\dos\main.exe");
If not, print "file could not be found."
I am trying to develop a DOS-like system which will be able to do all minor functions like cd.. cd/ and changing to sub directories.
Guys I am stuck in how to find a single path for many files.....
Thanx in ADVANCE
Well, if you are trying to executing those DOS command through your code. The only piece of work which you will have to do is to format the command and then look at the directory structure and then pass the formatted command to the system function. That should probably simulate all the simple commands that you want.
But then again, if your using the system function you haven't really achieved of anything writing your version of Windows DOS!
The problem with using the system() functions to do a lot of things is that whever you wanted it to do just disappears as soon as the system() function finishes. For example: lets say you want to change directories to c:\windows so you issue the command system(cd c:\\windows"); The system() function will execute the dos command, but as soon as system() returns to your program the program's current working directory will not have changed. To make such a command permanent in your program, it needs to issue equivalent C functions, in this case _chdir("c:\\windows");