Thread: How to execute file commands?

  1. #1

    Question How to execute file commands?

    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

  2. #2
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    for C look up fopen(), fclose(), fread(), fwrite(), fprintf(), fgetc() ....most members of the f-prefixed family

  3. #3
    Registered User
    Join Date
    Dec 2001
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  4. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM