TinyURL widget - shorten your URL's for free!

Enter a long URL to make tiny:

Wednesday, October 5, 2016

Trouble with 2 Functions in C [on hold]

Sorry people on Stackexchange tend to be lonely angry introverts looking for needy people to show how smart they are, so they bicker more with format, rather than just answering your question:

I think you are asking how do you "call on" or access the function variables you sent inside the function.

You don't post "Type" so let's use the example of "Student".

Since you pass a pointer to an array of Students called "class"  you would access the Students directly - you are working on the original not a copy.

     class->weightavg

would get you the double value inside class ASSUMING your pointer was to one and only one student in class[0] which is the same as class-> or pointer to the first array element.

If you have more than one which is what I believe your length variable is for, then it would be

    class[length].weightavg

for the double value.

or if you had a bunch of students then make an int i, iterate it, and


    class[i].weightavg

so long as you check up to length but not AT length (C arrays start from 0 not 1) so length should be outside the array.

your char * strings are a special case, look up strcpy() like functions or use printf("%s", class[i].name ); to show that value.

BTW: I addressed the kind of unhelpful anti-social behavior that goes on in stack exchange here where I poked the lonely introverts and they responded exactly the way I predicted.