Thread: Argv And Argc

  1. #1
    Unregistered
    Guest

    Argv And Argc

    could anyone post some examples of argc and argv for me. I am unsure about it. I have to create a program reading a text file using argv and argc. And then writing it to a binary. That part I understand.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    #include <stdio.h>
    
    int main ( int argc, char * argv[] )
    {
        int x;
        for( x = 0; x < argc; x++ )
            printf("argv[%d] is: %s\n", x, argv[x] );
        return 0;
    }
    This will print the entire command line set you use to invoke said program.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Ah, the two most important parameters in a C program. You will find them to be extremely useful in your production, especially with file specification. Enjoy!

    --Garfield

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help getting a grib on argc and argv
    By elwad in forum C Programming
    Replies: 10
    Last Post: 05-01-2009, 10:13 AM
  2. Using argc and argv data
    By Rad_Turnip in forum C Programming
    Replies: 4
    Last Post: 03-31-2006, 06:09 AM
  3. Converting a argc / argv construct into a va_list
    By chambece in forum C Programming
    Replies: 6
    Last Post: 07-03-2005, 04:47 PM
  4. argc & argv
    By miryellis in forum C Programming
    Replies: 11
    Last Post: 09-19-2004, 11:59 PM
  5. how do i? re: argc - argv
    By luigi40 in forum C Programming
    Replies: 2
    Last Post: 06-11-2004, 10:17 AM