C Language Using pointer parameters to return multiple values


Example

A common pattern in C, to easily imitate returning multiple values from a function, is to use pointers.

#include <stdio.h>

void Get( int* c , double* d )
{
    *c = 72; 
    *d = 175.0;
}

int main(void)
{
    int a = 0;
    double b = 0.0;

    Get( &a , &b );

    printf("a: %d, b: %f\n", a , b ); 

    return 0;
}