Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7556367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:50:48+00:00 2026-05-30T11:50:48+00:00

As the question mentions, how do command line arguments work in C(in general any

  • 0

As the question mentions, how do command line arguments work in C(in general any language). The logical explanation I could think of is, the operating system sets some kind of environmental values for the process when it starts.
But if it’s true I should not be able to access them as argp[i] etc(I modified the main to expect the 2nd argument as char **argp instead of **argv). Please explain.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:50:49+00:00Added an answer on May 30, 2026 at 11:50 am

    I’ll try to explain the implementation a bit more than other answers.
    I’m sure there are inaccuracies, but hope it describes the relevant parts well enough.

    Under the shell, you type ./myprog a b c.
    The shell parses it, and figures out that you want to run ./myproj with three parameters.
    It calls fork, to create a new process, where ./myprog would run.
    The child process, which still runs the shell program, prepares an array of 5 character pointers. The first will point to the string ./prog, the next three are to the strings a, b and c, and the last is set to NULL.
    Next, it calls the execve function, to run ./myprog with the parameter array created.
    execve loads ./myprog into memory, instead of the shell program. It releases all memory allocated by the shell program, but makes sure to keep the parameter array.
    In the new program, main is called, with the parameter array passed to it as argv.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Documentation for Android SDK, API 8, the javadoc for class android.test.InstrumentationTestRunner mentions command-line
This question talks about using the system command and passing variables. Here is an
I would like an Android build system procedure, command line or Eclipse, to generate
Question Can I build a image database/library that has an e-commerce style checkout system
Another SO question mentions a fantastic quine by Yusuke Endoh. A quine is a
Related question: Any good reason why assignment operator isn't a sequence point? From the
This question mentions that it is possible to go about implementing a linked list
As this Question's Answer from hightechrider mentions that code block as below is more
This question also has the answer , but it mentions DB2 specifically. How do
This question is related to another existing SO question . HttpServletRequest's getSession(boolean) method mentions

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.