Take values from a vector and use in a function

Asked

Viewed 65 times

0

I have a vector XC[i] where Gero with the code below:

for(i = 0;i<N_Volumes;i++){
        double XC[i];       
        XC[i] = (xC0+=delta_x)-1.0; 
        printf ("XC[%d]= %f\n", i, XC[i])};

I want to take these values from XC[i] and use in function double Sp= XC[i]*XC[i]

How can I do that?

  • Start by correcting the syntax of your commands.

1 answer

0


You need to pass as a parameter in the function. Example

void funcaoVetor(int vetor[]) {
 //código da função aqui
}
//chamada da função
funcaoVetor(vetor[50]);

However there is a difference in the passages, you can pass by parameter changing the values of this vector or as a reference where the change occurs only within the function, but does not change the value of the variable. But from what you have quoted I believe that is the passage in parameter so just do as any variable.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.