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
    Buea, Cameroon
    Posts
    197

    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
    Buea, Cameroon
    Posts
    197
    I'm thinking probably of using 'getopt' and optarg here, but not sure how.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    3,031
    look at the exec family of functions, and popen. popen is probably the best choice for what you want to do.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

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, 07:56 AM
  2. Adding commands to common context menus
    By Orderbringer in forum Windows Programming
    Replies: 2
    Last Post: 04-19-2005, 07:18 PM
  3. Adding colour to programs in Turbo C
    By Kurupt in forum C Programming
    Replies: 1
    Last Post: 11-05-2004, 12:16 AM
  4. Commands for terminating programs?
    By GuanoApes1234 in forum C++ Programming
    Replies: 1
    Last Post: 01-27-2003, 03:26 PM
  5. Adding Icons to your programs
    By Dual-Catfish in forum C++ Programming
    Replies: 6
    Last Post: 01-17-2002, 04:50 PM

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