Is there a way to "return" multiple values to call inside another function? C++

51 Views Asked by At

I've been struggling with this one for the last day or so. I am only a little over a month into my C++ journey so trying to just understand any and all good quality options to answer my issue.

The issue: To give a little more context, I have setup a function to find the max value and the index of this max value within a 26 character array, assigning both of these results as their own separate variables. This is to be then passed to the main function where the results can be outputted to the console in 2 separate "cout" statements.

I am able to return only one variable, it seems.

As I'm new, I'm all ears for anyone that wants to laugh at me or even give a little advice.

What I have tried so far (with help from other stackoverflow questions) : I have tried to assign both variables to a 2 element array, then returning the array, instead of returning both variables comma-separated. However, it only returned the first element of array.

Using answers from other stackoverflow questions that have been answered, I have tried using pairing statements and using structs but was messy and didn't return my expected results anyways as functions like tuple are not supported on my University version of c++ :/

0

There are 0 best solutions below