Here is my function that in my belief (I am still trying to get used to pointers) returns a pointer to the first element of the array named cords:
int* getPosition( char arr[][5], char letter ) {
int cords[2];
for ( int y = 0; y < 5; y++ ) {
for ( int x = 0; x < 5; x++ ) {
if ( arr[y][x] == letter ) {
cords[0] = x;
cords[1] = y;
}
}
}
return cords;
}
Here's my second function:
string scrambling( char arr[][5], vector<string> *pairs ) {
string encrypted;
int firstCords[2];
...
}
I want to somehow assign values from the array "cords" from the function getPosition to the array firstCords in the function scrambling().
My temporary solution was:
firstCords[0] = getPosition( arr, (*pairs)[i][0] )[0];
firstCords[1] = getPosition( arr, (*pairs)[i][0] )[1];
And it's the only solution I came up with that actually works. I'm really keen on getting to know a way, how I can achieve this in one line ?