Thread: Executing DOS command in C

  1. #1
    Registered User
    Join Date
    Jul 2006

    Executing DOS command in C


    How to execute any DOS command like"print abc.txt" in a C program
    friendz help me ? awating 4 u r answers....
    Thank u in advance !

  2. #2
    Registered User
    Join Date
    Jun 2006

    I am also beginner in C, but this should work as I see:

    #include <stdlib.h>
    #include <stdio.h>

    int main()
    printf("Your command\n");
    system("print abc.txt");
    return 0;

  3. #3
    Registered User
    Join Date
    Jun 2006
    system() function can help to execute your commands

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    If you want to capture the output of the command, redirect the output of the command into a file, then open that file, or look into the POSIX function popen().

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Executing DOS commands from inside an image
    By Moony in forum C Programming
    Replies: 6
    Last Post: 03-16-2008, 12:40 PM
  2. File systems?? (Winxp -> DOS)
    By Shadow in forum Tech Board
    Replies: 4
    Last Post: 01-06-2003, 09:08 PM
  3. Executing in DOS...
    By Jperensky in forum C Programming
    Replies: 5
    Last Post: 03-16-2002, 03:33 AM
  4. dos closes right away after executing
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 01-18-2002, 03:59 AM
  5. DOS program versus DOS console program
    By scromer in forum A Brief History of
    Replies: 4
    Last Post: 01-10-2002, 01:42 PM