Forums Assignment Help How can I invoke another program (a standalone executable

This topic contains 1 reply, has 1 voice, and was last updated by  Aakanksha 7 years, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1237

    Aakanksha
    Participant

    How can I invoke another program (a standalone executable, or an operating system command) from within a C program?

    #9800

    Aakanksha
    Participant

    Use the library function system, which does exactly that.

    Some systems also provide a family of spawn routines which accomplish approximately the same thing. system is more portable” in that it is required under the ANSI C Standard, although the interpretation of the command string–its syntax and the set of commands accepted–will obviously vary tremendously.

    The system function calls” a command in the manner of a subroutine, and control eventually returns to the calling program. If you want to overlay the calling program with another program (that is, a chain” operation) you’ll need a system-specific routine, such as the exec family on Unix.

    Note that system’s return value is at best the command’s exit status (although even that is not guaranteed), and usually has nothing to do with the output of the command.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.