//----------------------------------------------------------------- // 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 // revised on: 04 MAY 2009 -- for the x86_64 Linux environment //----------------------------------------------------------------- #include // for printf(), fprintf() #include // for atol() extern "C" long gcd( long, long ); int main( int argc, char *argv[] ) { long x, y, z; if ( argc < 3 ) { fprintf( stderr, "missing arguments\n" ); return 1; } x = atol( argv[1] ); y = atol( argv[2] ); z = gcd( x, y ); printf( "\n\t\t gcd( %ld, %ld ) = %ld \n\n", x, y, z ); }