home *** CD-ROM | disk | FTP | other *** search
- /* ------------------------------------------------------ */
- /* STRSTR.CPP */
- /* This program takes the average of numbers entered at */
- /* the command line. */
- /* (c) 1991 Borland International */
- /* All rights reserved. */
- /* ------------------------------------------------------ */
- /* veröffentlicht in DOS toolbox 3'92 */
- /* ------------------------------------------------------ */
-
- #include <strstream.h>
- #include <string.h>
-
- /* ------------------------------------------------------ */
-
- main( int argc, char *argv[] )
- {
- unsigned u;
- double total = 0, average = 0, d = 0;
-
- if ( argc == 1 ) {
- // Not enough command line parameters!
- cout << endl
- << "Usage <filename> float float ...." << endl;
- return 1;
- }
-
- for ( u = 1; u < argc; ++u ) {
- istrstream istr( argv[u], strlen(argv[u]) );
- istr >> d;
- total += d;
- }
-
- average = total / (argc - 1);
- cout.setf( ios::fixed, ios::floatfield );
- cout << endl << "AVERAGE = " << average << endl;
- return 0;
- }
- /* ------------------------------------------------------ */
- /* Ende von STRSTR.CPP */
-
-