| | |
Coding for DOS
![]() |
•
•
Join Date: Mar 2009
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
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!!
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.
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.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
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."
Will execute system("dir c:\myprogram\")
C Syntax (Toggle Plain Text)
cd c:\myprogram
(remember to check if it exsists)
C Syntax (Toggle Plain Text)
main
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."
C Syntax (Toggle Plain Text)
dir
Last edited by Hiroshe; Mar 22nd, 2009 at 1:13 pm.
"Sometimes, when I lie in bed at night and look up at the stars, I think to myself, "Man! I really need to fix that roof."-Jack Handy
•
•
•
•
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
But then again, if your using the system function you haven't really achieved of anything writing your version of Windows DOS!
-ssharish
"Any fool can know, point is to understand"
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"); Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Similar Threads
- Input buffer help transferring between Dos > Unix (C++)
- Making a python DOS-esque script into a GUI? (Computer Science)
- C++ trainer coding (C++)
- c++ letter coding (C++)
- Sending a dos environment variable to fstream instance (C++)
- DOS Graphics (Game Development)
- Half Life 2 SDK; Coding help wanted (C++)
- Graphics in Pixel,Mode13h:Part 1 (C++)
- Novell Finished (TEK) (Novell)
Other Threads in the C Forum
- Previous Thread: Question on regular expressions in vi
- Next Thread: Relatively Prime
| Thread Tools | Search this Thread |
adobe api array arrays binarysearch calculate char cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators intmain() iso kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix microsoft motherboard mqqueue mysql oddnumber odf open opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer posix power probleminc program programming pyramidusingturboccodes read recursion recv recvblocked repetition research scanf scheduling segmentationfault send shape socketprograming socketprogramming stack standard strchr string suggestions systemcall test unix urboc user variable voidmain() wab win32api windows.h






