943,769 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 628
  • C RSS
Mar 19th, 2009
0

Coding for DOS

Expand Post »
Hi,
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vinitt88 is offline Offline
2 posts
since Mar 2009
Mar 19th, 2009
0

Re: Coding for DOS

Are you trying to emulate a DOS environment using C? Post the relevant code you have already, what it is supposed to do, and what it is doing wrong.
Reputation Points: 128
Solved Threads: 43
Posting Whiz
death_oclock is offline Offline
389 posts
since Apr 2006
Mar 20th, 2009
0

Re: Coding for DOS

Are you trying to emulate a DOS environment using C? Post the relevant code you have already, what it is supposed to do, and what it is doing wrong.

yaa thats correct I need to emulate DOS environment in C.

I m yet to start the exact coding part
I am confused in system() function and windows.h files

I need to make a file which when executed must take you to the respective directory or sub directory of a given directory.

File Handling will be an alternative but I would have to make links to all ssub directories when I would like to access all of them one at a time.

This according to me requires handles not pointers.

I am confused in this concept!!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vinitt88 is offline Offline
2 posts
since Mar 2009
Mar 20th, 2009
0

Re: Coding for DOS

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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Mar 22nd, 2009
0

Re: Coding for DOS

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:
  1. cd c:\myprogram
The current directory variable now holds: c:\myprogram\
(remember to check if it exsists)
  1. main
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."
  1. dir
Will execute system("dir c:\myprogram\")
Last edited by Hiroshe; Mar 22nd, 2009 at 1:13 pm.
Reputation Points: 431
Solved Threads: 17
Posting Whiz in Training
Hiroshe is offline Offline
255 posts
since Jun 2008
Mar 22nd, 2009
0

Re: Coding for DOS

Click to Expand / Collapse  Quote originally posted by vinitt88 ...
Hi,
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!

-ssharish
Reputation Points: 73
Solved Threads: 20
Posting Whiz in Training
ssharish2005 is offline Offline
253 posts
since Dec 2006
Mar 22nd, 2009
0

Re: Coding for 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");
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Question on regular expressions in vi
Next Thread in C Forum Timeline: Relatively Prime





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC