I'm trying to make a program that allows the user to display a list of students with a specified gender. It asks the user to enter the gender and this function will return the indexes of all students with the specified gender. It must return a pointer. However, in my solution the pointer stores only one element and I can't figure out out.What am I doing wrong here?
This is my code:
You have 2 choices. You can create a new list with all the values found that match your search, or you can print as you search (each time you find one, you print it). The new list could be a list of pointers or indices to the data instead of a copy of the data, to save space.
You can only return ONE thing from a function once. That is, as soon as you call return, the function ends, and it can only return one thing at that point (that one thing could be a list, though). A different function format with reference parameters can return multiple things, but that does not work for this type of problem (but if you wanted to create a list of all males and another list of all females it could return both lists that way).
that would look like
void getlists(input, type *femalelist, type*malelist); //pointers are by reference