Results 1 to 3 of 3

Thread: Command Line Arguments

  1. #1
    Expert Member
    Join Date
    May 2008
    Answers
    100

    Thumbs up Command Line Arguments

    Please anybody can explain me how to use command line arguments in c.
    I am using TURBO C compiler.


  2. #2
    Expert Member
    Join Date
    Jan 2008
    Answers
    133

    Re: Command Line Arguments

    tcc -Iinclude -Llib hello.c

    is a sample. Simple tcc is the command and the minuses are options which you supply according to your program requirements and the hello.c is a sample program. Try similarly.

    Check the correct path settings and run the options as your program requires in terms of libraries...

    ---
    C program run. C program crash. C programmer quit.

  3. #3
    Expert Member
    Join Date
    Mar 2012
    Answers
    208

    Re: Command Line Arguments

    In c programming it is possible to pass arguments to C programs when they are executed. The brackets which follow main are used for this purpose.

    Example:

    #include <stdio.h>
    main( int argc, char *argv[] )
    Here argc refers to the number of arguments passed, and argv[] is a pointer array which points to each argument which is passed to main.
    *argv[0] is the name of the program invoked, which means that *argv[1] is a pointer to the first argument supplied, and *argv[n] is the last argument. If no arguments are supplied, argc will be one. Thus for n arguments, argc will be equal to n + 1.


  4.  Sponsored Ads
    Ad


     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact