//----------------------------------------------------------------- // gcdcalc.cpp // // This program calls an external function which employ's the // Euclidean Algorithm to compute the greatest common divisor // for a pair of integers, entered as command-line arguments. // // compile using: $ g++ gcdcalc.c gcd.o -o gcd // // programmer: ALLAN CRUSE // written on: 05 MAR 2006 //----------------------------------------------------------------- #include // for printf(), fprintf() #include // for atoi() extern "C" int gcd( int, int ); int main( int argc, char *argv[] ) { int x, y, z; if ( argc < 3 ) { fprintf( stderr, "missing arguments\n" ); return 1; } x = atoi( argv[1] ); y = atoi( argv[2] ); z = gcd( x, y ); printf( "\n\t\t gcd( %d, %d ) = %d \n\n", x, y, z ); }