IHYPRESS PROGRAMMING
Tutorials and C programs with code and output for beginners
c programming
HOME | ASP | C | CSS | GNUPLOT | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
CAdvanced Programming : Numerical Command Line Arguments
<12.02>
/* This program accepts two arguments in a specific order: 1) an integer number 2) a double number and sums them up */ #include <stdio.h> #include <stdlib.h> int main (int argc, char *argv[]) { int a; double x, sum; if (argc == 3) { printf("The arguments supplied are %s and %s.\n", argv[1], argv[2]); a = atoi (argv[1]); /* convert string to integer */ x = atof (argv[2]); /* convert string to double */ sum = a + x; printf ("The sum is: %f\n", sum); } else if (argc > 3) printf ("ERROR: Too many arguments supplied.\n"); else printf ("ERROR: One argument expected.\n"); return (0); }
Hergestellt in Deutschland / Made in Germany
Microsoft(R) Windows DOS (C)Copyright Microsoft Corp 1990-2001. A:\> argadd.exe 8 4.21 The arguments supplied are 8 and 4.21. The sum is: 12.210000 A:\>
COPYRIGHT © 2015-2024 IHY PRESS Frankfurt am Main 60329 Deutschland