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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:20:18+00:00 2026-06-10T10:20:18+00:00

I understand how arrays decay to pointers. I understand that, for the compiler, this:

  • 0

I understand how arrays decay to pointers. I understand that, for the compiler, this:

void foo(int *arg1);

is 100% equivalent to this:

void foo(int arg1[]);

Should one style be preferred over the other? I want to be consistent, but I’m having a hard time justifying either decision.

Although int main(int argc, char *argv[]) and int main(int argc, char **argv) are the same, the former seems to be much more common (correct me if I’m wrong).

  • 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-10T10:20:19+00:00Added an answer on June 10, 2026 at 10:20 am

    I would recommend against using the [] syntax for function parameters.

    The one argument in favour of using [] is that it implies, in a self-documenting way, that the pointer is expected to point to more than one thing. For example:

    void swap(int *x, int *y)
    double average(int vals[], int n)
    

    But then why is char * always used for strings rather than char []? I’d rather be consistent and always use *.

    Some people like to const everything they possibly can, including pass-by-value parameters. The syntax for that when using [] (available only in C99) is less intuitive and probably less well-known:

    const char *const *const words vs. const char *const words[const]

    Although I do consider that final const to be overkill, in any case.

    Furthermore, the way that arrays decay is not completely intuitive. In particular, it is not applied recursively (char words[][] doesn’t work). Especially when you start throwing in more indirection, the [] syntax just causes confusion. IMO it is better to always use pointer syntax rather than pretending that an array is passed as an argument.

    More information: http://c-faq.com/~scs/cgi-bin/faqcat.cgi?sec=aryptr#aryptrparam.

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

Sidebar

Related Questions

This one of the things that has always bothered me about Matlab. I understand
I understand that memberwise assignment of arrays is not supported, such that the following
As I understand assigning arrays is a Memory copy operation, will this work? struct
I can't understand why these arrays give me different outputs: • this value 1/4
I am trying to understand pointers and arrays. After struggling to find pointers online(pun!),
I understand the concept of pointers and arrays in C. My problem is the
So I understand that interior_ptr<typename> can be used to operate with arrays of structs
I'm using C++ to understand how exactly pointers work. I have this piece of
I understand that arrays in C are allocated in row-major order. Therefore, for a
I'm trying to wrap my head around three-dimensional arrays. I understand that they are

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.