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 8868931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:22:08+00:00 2026-06-14T17:22:08+00:00

As we know, array name can’t be assigned, sentence like: char * array[], *

  • 0

As we know, array name can’t be assigned, sentence like:

char * array[], * point;
array = point; /* wrong */
array++; /* wrong */

But in main(int argc, char * argv[]), argv++ is ok and works well.
What do i missing?

  • 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-06-14T17:22:10+00:00Added an answer on June 14, 2026 at 5:22 pm

    In the context of a function parameter declaration, T a[] and T a[N] are both interpreted as T *a; in all three cases, a is declared as a pointer to T, not an array of T. Thus, in int main(int argc, char *argv[]), argv is really declared as char **, or pointer to pointer to char, not array of pointer to char.

    (edit — note that this is true only for function parameter declarations; for a regular variable declaration, T a[N] and T a[] both declare a as an array of T).

    Since it’s a pointer value, it can be assigned to and it can be incremented.

    Beyond that, here’s what the language standard has to say:

    5.1.2.2.1 Program startup

    …
    2 If they are declared, the parameters to the main function shall obey the following
    constraints:
    …
    — The parameters argc and argv and the strings pointed to by the argv array shall
    be modifiable by the program, and retain their last-stored values between program
    startup and program termination.

    EDIT

    And here’s the language for function parameters:

    6.7.6.3 Function declarators (including prototypes)

    …
    7 A declaration of a parameter as ‘‘array of type’’ shall be adjusted to ‘‘qualified pointer to
    type’’, where the type qualifiers (if any) are those specified within the [ and ] of the
    array type derivation. If the keyword static also appears within the [ and ] of the
    array type derivation, then for each call to the function, the value of the corresponding
    actual argument shall provide access to the first element of an array with at least as many
    elements as specified by the size expression.

    EDIT2

    Some examples (assumes a C99 compiler):

    void foo(int a[], size_t len)
    {
      size_t i;
      printf("sizeof a = %zu\n", sizeof a);
      printf("sizeof (int *) = %zu\n", sizeof (int *));
      for (i = 0; i < len; i++)
        printf("a[%zu] = %d\n", i, *a++);
    }
    
    int main(void)
    {
      int a1[5] = {0};
      int a2[]  = {0, 1, 2, 3, 4};
    
      printf("sizeof a1 = %zu\n", sizeof a1);
      printf("sizeof a2 = %zu\n", sizeof a2);
    
      foo(a1, sizeof a1 / sizeof a1[0]);
      foo(a2, sizeof a2 / sizeof a2[0]);
    
      return 0;
    }
    

    One more piece of standardese:

    6.3.2.1 Lvalues, arrays, and function designators

    …
    3 Except when it is the operand of the sizeof operator, the _Alignof operator, or the
    unary & operator, or is a string literal used to initialize an array, an expression that has
    type ‘‘array of type’’ is converted to an expression with type ‘‘pointer to type’’ that points
    to the initial element of the array object and is not an lvalue. If the array object has
    register storage class, the behavior is undefined.

    In the function main, a1 and a2 have been declared as 5-element arrays of int; a2 gets its size from the number of elements in the initializer. The expressions a1 and a2 thus have types “5-element array of int” and they may not be targets of an assignment expression, nor may they be operands to the ++ or -- operators. When these expressions appear in the call to foo, their types are converted to “pointer to int” per the rule above. Thus foo receives a pointer value, not an array value, for a (which is covered by the rule that says array parameters are converted to pointer types). So the expression a in foo has type int *, or pointer to int; thus, a may be the target of an assignment, and it may be an operand of ++ and --.

    One more difference: per the rule quoted above, the conversion to a pointer type doesn’t happen when the array expression is an operand of the sizeof operator; sizeof a1 should evaluate to the number of bytes taken up by the array a1 (5 * sizeof int). However, since a in foo has type int *, not int [5], sizeof a should only evaluate to the number of bytes for an pointer to int (sizeof (int *)).

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

Sidebar

Related Questions

as we all know declaration of array is pretty simple type name[size]; but when
Can you do array['Name']; In C# Rather than: array[0]; I know you can do
I know that we can initialise an array in one of two ways: Loop
I have this combination of multi-dimensional array but I can't print the correct value
I want to know how i can post a multi-dimensional array? Basically i want
array_unique is to be used by passing the array name as a parameter. But
How can I search an array to know if there is a key=>value in
In PHP you can dynamically create variables $myarr = array('name'=>'Adam', 'age'=>22, 'sex'=>'male'); foreach ($myarr
I wanted to know is C# array has a constant access speed? I need
How is an array of string where you do not know where the array

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.