Firstly, str1 is not a
first
, it's an array of first objects:
first str1[4];
So your method definition has to match that, as it does with
cal
.
But there are problems here, as str2 is an array of 4 first objects, so this:
str2[0].member=fun(str2[4]);
Tries to access a fifth element of teh array - C indexes start at zero, remember.
If you are trying to pass a single instance of first to fun, then declare it as
void fun(first f) {
...
}
And call it with an element form one of your arrays:
fun(str1[0]);
fun(str1[1]);
fun(str1[2]);
fun(str1[3]);
fun(str2[0]);
fun(str2[1]);
fun(str2[2]);
fun(str2[3]);
If you want to pass an array of first objects:
void fun(first f[]) {
...
}
And pass it the array:
fun(str1);
fun(str2);
But either way, this won't work:
str2[0].member=fun(str2[4]);
Because fun is a void function - iut cannot return a value, so it can;t be used on the right of an equals sign.
I think you need to sit down and re-read your course notes: you appear to be a little confused as to what you are trying to do here.