Click to See Complete Forum and Search --> : compiler error
dc83
April 7th, 2003, 09:07 PM
I got this compiler error
"numeric constant contains digits beyond the radix"
in reference to this section of code
"if (month = 08)"
and I don't know why.
I don't get errors for anything else just the "if (month = 08)" and also for the 09. works for 01-07 though and 10-12.
galathaea
April 7th, 2003, 09:12 PM
The "0" in front implies octal notation. 8 is not a "digit" of the octal system. Just do not use a preceding 0 when you intend base 10.
dc83
April 7th, 2003, 09:28 PM
ok thanks. What if the user inputs an 09 though will that be recognized as 9?
galathaea
April 8th, 2003, 12:43 AM
Originally posted by dc83
ok thanks. What if the user inputs an 09 though will that be recognized as 9?
This all depends on how you read in the input. If you are using the default cin iostream and stream into an integer, it will read it in as a decimal value.
dc83
April 8th, 2003, 01:09 AM
im doing a simple cin >> month
Manish Malik
April 8th, 2003, 01:49 AM
Originally posted by dc83
im doing a simple cin >> month
Depends pretty much on current stream flags.
If you want to be absolutely sure,
#include <iostream>
int main() { int month; std::cin.setf(std::ios_base::dec,std::ios_base::basefield); std::cin >> month; std::cout << month; }
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.