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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:53:06+00:00 2026-05-27T02:53:06+00:00

I understand how to pass an array to a function and let that function

  • 0

I understand how to pass an array to a function and let that function update the value of the array. I’m having a tough time understanding how to pass an ELEMENT of an array to a function and have that function update that element. My guess is as below, but produces the following from gcc: "warning: conflicting types for 'CDivide'".

The main() function defines the arrays in question, and passes them (as reference) to fn_v1p0 as complex_real and complex_imag, where they’re declared as pointers in the function definition for fn_v1p0. The main() includes prototypes for these functions, as follows.

void fn_v1p0(double *, double *, char *, double *, unsigned int, double *);
void CDivide(double *, double *, double, double, double, double);

However, the main() sits in one file and the other two functions sit in a different file. Only the main file includes these prototypes.

I need to perform complex division (not supported in ANSI C), which is the purpose of function CDivide. There’s more to the fn_v1p0 function, but I reduced it to only what’s necessary to show for this question.

I’ve treated complex_real[ii] as simply a double value, hoping that if I put an & in front of it then CDivide could be written as shown. But my guess isn’t working. Not sure what’s the best way to tackle this.

void fn_v1p0(
    double *complex_real, double *complex_imag, 
    char *selected_form,    
    double *freq,          
    unsigned int len_freq, 
    double *Hparams)
{
    int ii = 0;
    double a0, b0;

    for (ii = 0; ii <= len_freq; ii++) {
       CDivide( &complex_real[ii], &complex_imag[ii], b0, 0, a0, freq[ii] );
    } 
}

where

void CDivide( 
    double *z_real, double *z_imag, double a, double b, double c, double d) 
{
    double divisor = c*c + d*d; 
    *z_real = (a*c + b*d) / divisor; 
    *z_imag = (b*c - a*d) / divisor; 
}
  • 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-27T02:53:06+00:00Added an answer on May 27, 2026 at 2:53 am

    The problem was the prototype for the CDivide function needs to reside in the file containing the CDivide and fn_v1p0 definitions, and not the file containing the main() function. Moving the prototype for CDivide to the file containing CDivide clears the error. Thanks to Adam Rosenfield for flushing out the issue with his comments in the question above.

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

Sidebar

Related Questions

From what I understand: when you pass by value, the function makes a local
So I'm trying to create a function that takes in an array (I guess
I understand that some countries have laws regarding website accessibility. In general, what are
I'm having a hard time understanding what I'm supposed to do. The only thing
I (think I) understand that you can only retrieve the size of an array
I have a function that uses the ... rest argument as follows: public function
The time has come for me to understand MVC, so that's what I'm trying
So I need to pass to a JavaScript function an array of strings in
I'm trying to understand how my PHP script can pass an array to my
Is it possible to pass an anonymous function as an argument, and have it

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.