Thread: How does a C program come to know about command line arguments?

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    21

    Question How does a C program come to know about command line arguments?

    can any body explain it to me plz.

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    88
    int main(int argc, char** argv)

    do you mean that or explaining how that works?

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    The runtime or whatever executed the program parses and sends the command line arguments. For example a program in DOS is executed: DOS takes the command, parses it, tokenizes it and sends it to the client program's main.

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You could always read the nice little FAQ. But then, you'd be the first person to ever actually read the thing...

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

  5. #5
    Registered User
    Join Date
    Jun 2003
    Posts
    21
    i wanted to know at time of compilation how the program behave and how the memory is utilized ,also how the compiler behaves to it.
    "The New Testament offers the basis for modern computer coding theory, in the
    form of an affirmation of the binary number system. But let your communication
    be Yea, yea; nay, nay: for whatsoever is more than these cometh of evil."
    - Matthew 5:37

  6. #6
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    The point is quite simple. the reason C has int main() and int main(int, char **) is so that you don't have to re-write code for every OS you bring your program to. For example, in windows programs you would use WinMain(). WinMain() doesn't have a char **argv parameter it has a single dimensional string that you get to parse yourself. Your compiler hides (for lack of a better term) the part where a program takes a string from the OS shell and spits out char **argv.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Making a program take a variable number of arguments
    By subtled in forum C Programming
    Replies: 1
    Last Post: 04-17-2007, 05:38 AM
  2. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  3. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  4. running program with arguments (linux)
    By N8760 in forum C++ Programming
    Replies: 2
    Last Post: 01-28-2002, 02:08 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM