Adding linux commands to C programs

This is a discussion on Adding linux commands to C programs within the Linux Programming forums, part of the Platform Specific Boards category; Hi Guys, I'm currently working on a program which sorts a file and returns all the words in a file ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Location
    Douala, Cameroon
    Posts
    187

    Adding linux commands to C programs

    Hi Guys,

    I'm currently working on a program which sorts a file and returns all the words in a file together with their frequencies, I'm thinking of using linux commands like "wc" "sort" and others which I know can do the Job I'm thinking of a way of integrating these commands directly into the c program including 'probably' the necessary header files and libraries, without actually calling the commands with argv. Could some one please help me out here?

    Thanks,
    Nyah

  2. #2
    Registered User
    Join Date
    Nov 2011
    Location
    Douala, Cameroon
    Posts
    187
    I'm thinking probably of using 'getopt' and optarg here, but not sure how.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    2,421
    look at the exec family of functions, and popen. popen is probably the best choice for what you want to do.
    Code:
    namespace life
    {
        const bool change = true;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Running linux system commands
    By Creini in forum C Programming
    Replies: 2
    Last Post: 05-27-2006, 06:56 AM
  2. Adding commands to common context menus
    By Orderbringer in forum Windows Programming
    Replies: 2
    Last Post: 04-19-2005, 06:18 PM
  3. Adding colour to programs in Turbo C
    By Kurupt in forum C Programming
    Replies: 1
    Last Post: 11-04-2004, 11:16 PM
  4. Commands for terminating programs?
    By GuanoApes1234 in forum C++ Programming
    Replies: 1
    Last Post: 01-27-2003, 02:26 PM
  5. Adding Icons to your programs
    By Dual-Catfish in forum C++ Programming
    Replies: 6
    Last Post: 01-17-2002, 03:50 PM

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