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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:46:45+00:00 2026-06-02T16:46:45+00:00

I would like to pass parameters instantly to function, without creating additional variable like

  • 0

I would like to pass parameters instantly to function, without creating additional variable like this:

void DrawSprite( float a[2], float b[2] ) { /* */ }

DrawSprite( (0.0f, 0.0f), (50.0f, 50.0f) );

Is it possible, and if yes, how to do it?

  • 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-02T16:46:47+00:00Added an answer on June 2, 2026 at 4:46 pm

    Some of the answers to this important question seem to be misleading. The issue is: passing a fixed size array to a function. First of all something like

      float x[2] = {0.1F, 0.2F};
      float y[2];
      y=x;
    

    is a error: invalid array assignment (on gcc 4.6.1; but we should be speaking on “standard” here, not particular compiler features). Quite rightly so — what should the operation accomplish? Both x and y point to a piece of memory on stack, so copying the float* x to y would make little sense, as the values will not be copied to the place reserved initially, y[0],y[1].

    The only sensible cast from float x[2] is to float *y. This is precisely what happens when a function is called. Your function DrawSprite(float a[2], float b[2]) is really treated as DrawSprite(float* a, float* b) (you might print out typeid(a).name() to check). Therefore you can pass x to DrawSprite, and this x will simply be cast to float*.

    The second issue is initialization. The code (float[2]){1.0, 2.0} really constructs a fixed-size temporary array of float (again can be checked by typeid((float[2]){1.0, 2.0}).name(), at least on gcc), but there is not much you can do with this array, as assignments to float [2] are forbidden. You may cast it to float* (e.g. assign by z=(float[2]){1.0,2.0};, but to float* z;, so it is really z=(float*)(float[2]){1.0,2.0};), or you may pass it to your function, which does the same, i.e. casts to float*.

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

Sidebar

Related Questions

i would like to pass multiple parameters in my callback function and don't know
I would like to know whether it is possible to pass parameters from a
I would like to have a function that modifies some variable list of parameters
I would like to know if it's possible to pass a parameter to a
I would like to pass to a jQuery function a regular function, instead of
I hava a perl subroutine where i would like to pass parameters as a
I've implemented a MXML custom components and I would like to pass parameters to
I would like to pass parameter from view to controller in cshtml page. This
I am trying to pass in url parameters to a django template like this...
I would like to pass some parameters to a web method as an 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.