Mar 29, 2012 at 9:34am UTC
Only part of the code that doesn't work, Trying to get this part of coding to accept one decimal e.g 2.34 and if there was 2.3454.54 the output would be X.
I know you do this with string but coding hasn't worked out well
if (argc==4)
{
float num1= atof(argv[1]);
float num2 = atof(argv[2]);
string operation = argv[3];
int decCount(0);
string ch1 = (argv[1]);
string ch2 = (argv[2]);
if(ch1 = ".")
{ decCount ++ ;
if(decCount > 1 )
{ cout << " X " << endl;}
}
if(ch2 = ".")
{ decCount ++ ;
if(decCount > 1)
{cout << "X" << endl;}
}
_________________________________ After this Part works
if(operation == "a")
{cout << num1+num2 << endl;}
..... code continues.
Thanks for any help
Last edited on Mar 29, 2012 at 9:35am UTC
Mar 29, 2012 at 10:16am UTC
So you're trying to check if a number only has a certain number of numbers after the decimal place?
Mar 29, 2012 at 11:03am UTC
No i'm checking for decimal points which is the dot "." anything with more than one dot should cout X