Thread: about commandline arguments

  1. #1
    Registered User
    Join Date
    Apr 2002

    about commandline arguments

    Hi fellows,

    I have little program here that I want to incorprate some more
    commandline arguments and it would be run this way:

    <proramname> rounds FFFFF ENC < fileIn > fileOut
    -------- ------- -----

    rounds = number of rounds in a loop
    FFFFFF = hex value used as key
    ENC = means to be encrypted

    the underlined args are the new ones and also would like to
    use in loop as stopping condition.

    can anyone tell me how can incoorprate the 3 more args ?

    thanks in advance.

    here is tha program:

    /* Function: Open files */
    bool open_files (FILE *infile, FILE *outfile)
        bool retval;
        infile = fopen ("test.txt", "r");
        outfile = fopen ("res.txt", "w");
        if (infile == NULL || outfile == NULL)
            close_files (infile, outfile);
            retval = false;
            retval = true;
        return retval;

  2. #2
    Join Date
    Sep 2001
    > can anyone tell me how can incoorprate the 3 more args ?
    I'd love to help, but it seems as if I am only presented with a file manipulating function that accepts file input & output.

    I don't see any attempt at your command line parameter section, or even the general area of the code where it's at.

    Do a search for command line arguments through these baords.
    The world is waiting. I must leave you now.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > can anyone tell me how can incoorprate the 3 more args
    Since your program had no arguments to start with....

    proramname < fileIn > fileOut
    Has no arguments, it has redirections which are managed by the shell, and your program just deals with stdin and stdout

    Simple args code
    int main ( int argc, char *argv[] ) {
      int i;
      for ( i = 0 ; i < argc ; i++ ) {
        printf( "Arg %d is %s\n", i, argv[i] );
      return 0;
    Once you know where/how "rounds FFFFF ENC" appear, you should be able to figure out how to use them

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GradeInfo
    By kirksson in forum C Programming
    Replies: 23
    Last Post: 07-16-2008, 03:27 PM
  2. command line arguments
    By vurentjie in forum C Programming
    Replies: 3
    Last Post: 06-22-2008, 06:46 AM
  3. Replies: 10
    Last Post: 09-27-2005, 12:49 PM
  4. NULL arguments in a shell program
    By gregulator in forum C Programming
    Replies: 4
    Last Post: 04-15-2004, 10:48 AM
  5. my own commandline parser function
    By scrappy in forum C Programming
    Replies: 7
    Last Post: 08-22-2003, 02:57 AM