Hi,
Im extremely new to programming and therefore am in need of assistance.
What im trying to do is add a range limit to a if(argc == 3) although it already has a if within AND an else function.
i.e
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
if (argc==3)
{
if(isalpha(*argv[1]) && isalpha(*argv[2]))
{
cout<<"X"<<endl;
}
else
{
double x =atof(argv[1]);
double y =atof(argv[2]);
double answer = x+y;
cout<<answer;}
return 0;
so how would i go about restricting the range of numbers used?
If data is submitted by command line arhuments, youcan't prevent the user from typing whatever he wants. So you'll have to check if what is enter is correct, and handle it in the way that is appropriate for your program (asking them again, aborting the program, using default values,...)