Executing DOS command in C

This is a discussion on Executing DOS command in C within the C Programming forums, part of the General Programming Boards category; HI, How to execute any DOS command like"print abc.txt" in a C program friendz help me ? awating 4 u ...

  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    10

    Executing DOS command in C

    HI,

    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
    Posts
    130
    Hi,

    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
    Posts
    130
    system() function can help to execute your commands

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    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().
    dwk

    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: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    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, 08:08 PM
  3. Executing in DOS...
    By Jperensky in forum C Programming
    Replies: 5
    Last Post: 03-16-2002, 02:33 AM
  4. dos closes right away after executing
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 01-18-2002, 02:59 AM
  5. DOS program versus DOS console program
    By scromer in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 01-10-2002, 12:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21