Hello, I am working on a project, but have found my self stuck on one section.
I have a function called:
arrayToInteger(int digits[], int length)
which as the title suggests, it takes the integer values in each cell of the array and joins them together to make a single integer. So an array of [1|0|1] becomes the integer 101.
The problem I am facing is that i need to make the "int digits[]" become a generic term so that I can pass in any array I want. I have set it up so I pass the array called "digits[]" into the function which works great, but I can't pass an array called "descend[]" into the function when I call it the second time.
Can you guys help me with this?
So what I'm looking for is arrayToInteger(int (any array)[], int length)
Here is the code:
int arrayToInteger(int digits[], int length )
{
std::stringstream ss;
for (unsigned i = 0; i < length; ++i)
ss << digits[i];
int integer = 0;
ss << integer;
cout << integer;
return integer;
}