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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:52:42+00:00 2026-06-17T10:52:42+00:00

So, arrays are pointers to their first element. float color[4]={rColor, gColor, bColor, alpha}; Thus,

  • 0

So, arrays are pointers to their first element.

float color[4]={rColor, gColor, bColor, alpha};

Thus, just plain color points to &color[0];

Now suppose I have a struct thusly:

struct Colors{
float color[4];
};

Now I have found I can do this quite fine:

Colors myColor={{*color}};

I could also just do this:

Colors myColor={{color[0]}};

I am only pointing at one element, but the struct expects 4, so it keeps looking past this element.

First, I want to check that is fine to do, legal and okay. Obviously if you are passing a large array, this is quite convenient on the syntax and typing.

Second, I want to verify the reasoning about why this works. Since color alone is a pointer, the * is an indirection operator that retrieves the memory pointed to, thus, the array. So essentially we get the entire array by just calling its pointer with indirection. Correct?

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

    Intializers of structures, unions and arrays have the particular property that elements that are omitted from it are initialized with 0.

    To initialize a whole structure as your Colors you can also use any other object of that same type.

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

Sidebar

Related Questions

I am a new C programmer and the pointers + arrays are messing me
If we can use pointers and malloc to create and use arrays, why does
I am a hobbyist console C++ developer. I have worked with pointers, arrays, std::vectors,
I have these 2 fairly large arrays, one with pointers and one with strings
Here is a code which print the address of the first element of an
Comparing LinkedLists and Arrays while also comparing their differences with sorted and unsorted data
Are array of pointers to different types possible in c++? with example please)
Can c++ create array of pointers to different classes dynamically loaded from dll? ps.without
_stuckVertices is an array of pointers and I would like to update one index
I have an array of pointers to a base class, so that I can

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.