I remember from programming in QBasic that there were ways to look at files on a disk. How can I check the contents of a disk in C++ (or C)? How can I do other DOS-type commands like cd or dir? Thanks
This is a discussion on How to execute file commands? within the C++ Programming forums, part of the General Programming Boards category; I remember from programming in QBasic that there were ways to look at files on a disk. How can I ...
I remember from programming in QBasic that there were ways to look at files on a disk. How can I check the contents of a disk in C++ (or C)? How can I do other DOS-type commands like cd or dir? Thanks
for C look up fopen(), fclose(), fread(), fwrite(), fprintf(), fgetc() ....most members of the f-prefixed family![]()
Gays can't love like real people
entropysink.com -- because arses weren't designed for running websites.
If you know the name of the files you want to open, or can prompt the user for the file name check out the ifstream class for input, the ofstream class for output.
There are C equivaliants that i am not famialar with. -KEN- already listed them.
If you want to use os system calls, check out the system() function.
It takes a char * and executes that command. So you could use the system function to do a "dir" command, and pipe the output to a text file, you could then open that text file and parse it for the name of files and directorys.