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

  • Home
  • SEARCH
  • 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 6111415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:37:39+00:00 2026-05-23T14:37:39+00:00

Recently, I was debugging one of my programs and found a mistake that I’ve

  • 0

Recently, I was debugging one of my programs and found a mistake that I’ve constantly make, but it was not shown as a warning during compilation, so I’ve just assume everything was in place and was OK. I a bit confused on what’s happening in the code below:

void foo(char b[2]);
char a[2] = {1, 2};
foo(a);   // I always assumed that this would pass the entire array to be
          // duplicate in stack, guess I was wrong all this while
          // Instead the address of the array was passed

void foo(char b[2])
{
   // Value of b[0], b[1]?
   // Does this mean :   1) b[0] == &a[0]?
   //                or  2) b[0] == &a[0+2]?
   // Compiler didn't complain, so I assume this is a valid syntax
}
  • 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-23T14:37:40+00:00Added an answer on May 23, 2026 at 2:37 pm

    When you pass an array as a parameter to a function it decays into a pointer, this is defined in the C standard in 6.7.1:

    On entry to the function the value of each argument expression shall be converted to the type
    of its corresponding parameter, as if by assignment to the parameter. Array expressions and
    function designators as arguments are converted to pointers before the call. A declaration of a
    parameter as “array of type” shall be adjusted to “pointer to type,”

    This essentially means that in your function declaration it’s equivalent to use

    void foo(char b[2]); or
    void foo(char b[]); or
    void foo(char *b)

    `

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

Sidebar

Related Questions

I'm currently using UKPhoneNumberField in one of my forms. I recently found that if
I have recently been put in charge of debugging two different programs which will
I spent a lot of time recently reading about debugging. One of the aspects
Recently several tools have been released such as pyjamas and Scheme2js that allow one
I recently noticed that one of my websites (the site is a self-hosted Wordpress
I recently spent a long while debugging something that turned out to be an
I'm not entirely sure what has happened. I was debugging a script that worked
I've been getting an error recently while debugging an ASP.NET application in Visual Studio
I was recently tasked with debugging a strange problem within an e-commerce application. After
Recently I had to develop a SharePoint workflow, and I found the experience quite

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.