if you go to dos and try to:
scandisk C: /parameter1 /parameter2
then
argc=4 and argv[0]=scandisk, argv[1]=c:, argv[2]=/parameter1, argv[3]=/parameter2
About the other part i dont know, cause i dont know c++ and looking through a ANSI C perspective, it seems all wrong :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
would you please explain why did the prof use
x[i-1]=atof(argv[i]) in this program.
and what does argc, and argv mean in this progaram.
#include <iostream>
#include <stdlib.h>
double findSmallLarge(int , double *, double &);
double findSmallLarge(int np, double x[], double &big)
{
double smallest = x[0];
for (int i = 1; i < np; i++)
if (smallest > x[i])
smallest = x[i];
big = x[0];
for (int i = 1; i < np; i++)
if (big < x[i])
big = x[i];
return smallest;
}
int main(int argc, char *argv[])
{
double x[50];
for (int i = 1; i < argc; i++)
x[i-1] = atof(argv[i]);
double smallest, biggest;
smallest = findSmallLarge(argc - 1, x, biggest);
cout << smallest << " " << biggest << endl;
system("PAUSE");
return 0;
}
About argc and argv:
if you go to dos and try to:
scandisk C: /parameter1 /parameter2
then
argc=4 and argv[0]=scandisk, argv[1]=c:, argv[2]=/parameter1, argv[3]=/parameter2
About the other part i dont know, cause i dont know c++ and looking through a ANSI C perspective, it seems all wrong :)
thank you very much, that helped..........