On May 4, 6:27??pm, Huub <v.niekerk_@_hccnet.nl> wrote:
Hi,
I made a function that should return 2 integers. But as the compiler
indicates in "return x,y", the x is ignored. So, it is even possible
what I want: returning 2 integers?
Thanks.
Hi Huub,
The previous poster is correct. This example demonstrates the "call by
reference" method to get what you want. This requires you to declare the
integers before the function is called. The function is giving te
addresses(or references) where the ints can be stored, the function does
that.
#include <stddef.h>
#include <stdio.h>
void GetTwoInts( int& a, int& b )
{
a = 3;
b = 4;
}
int main()
{
int x,y;
GetTwoInts( x, y );
printf( "x from function GetTwoInts: %d\n", x ); printf( "y from
function GetTwoInts: %d\n", y );
getchar();
return 0;
}
Good luck with programming!
Thank you. This works.