English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

5 answers

Given that you have not told us what programming language you are using, I must assume that this link is correct.

If you want to just access the data of the array then this should be correct. If you want to actually access the Array and perhaps change values then you need to be using a pointer.

I hope it helps.

2007-05-17 23:42:33 · answer #1 · answered by AnalProgrammer 7 · 0 0

i found right here issues on your code. listed from suited to backside. - there's no semicolon after the function prototype: double avg_val(double array[], int p2); - Variable "avg" replaced into no longer given a expertise style: double avg = ; - Variable "n" has no longer been initialized with a datatype or fee. - do no longer incorporate the brackets while passing the array into the function, basically in the prototype and assertion: double avg = avg_val(array, n); - function "avg_val" replaced into no longer declared with a return style. The signatures could desire to journey in the prototype and assertion: double avg_val(double array[], int n) { ... } basically a tip, ascertain you provide your variables significant names. right here is a few edited code: double avg_val(double array[], int length); int significant() { const int length = 5; double values[length] = {a million, 2, 3, 4, 5}; //code to initialize the array and different variables, examined and that i be attentive to it works double avg = avg_val(values, length); return 0; } double avg_val(double values[], int length) { //code for the avg_val function }

2016-12-11 12:56:38 · answer #2 · answered by Anonymous · 0 0

Just pass in a pointer of the structure type. 'C' will do pointer arithmetic (increments will be in the sizeof(struct type)) so you can just use the pointer as an array.

e.g.
typedef struct
{ int a; int b; }myType;

void f1(myType *mt)
{
int c;

c = mt[10].a;
}

void main(void)
{
myType array1[100];

array1[40[.a = 5;

f1(array1);
}

a nonsense example but hopefully it'll get the point across. variable c in f1 will have the value 5.
In 'C' pointers and arrays are usually treated the same and
are usually interchangeable. You should try to understand the
difference though.

2007-05-18 02:02:00 · answer #3 · answered by TC 3 · 0 0

In the language C, you would merely pass the idenfier:

// szName is an array of characters
char szName[13] = { "FredPChicken" };

void Print(const char* szText)
{
printf("%s\n", szText);
}

int main(int argc, char* argv[])
{
Print(szName);
}

2007-05-18 00:07:03 · answer #4 · answered by chronusmcgee 1 · 0 0

This is a c++ program to find subscript of maximum value in array

#include
using namespace std;
int findMax(const int array[], int maxSize);
int main()
{
int listOfNumbers[10];//array of integers
int maxIndex, //subscript of max value
count; //number of values

//function invocation
maxIndex = findMax(listOfNumbers, count);//send Array name & no of values

} //main

int findMax(const int array[], int maxSize) //find max in Array
{
int largest,
i;
largest = 0;
for(i=1; i if(array[i] > array[largest])
largest = i;

return largest;
} //findMax

I think this will help you.

2007-05-18 01:00:05 · answer #5 · answered by T & T 2 · 0 0

fedest.com, questions and answers