|
-
April 7th, 2003, 09:07 PM
#1
compiler error
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.
-
April 7th, 2003, 09:12 PM
#2
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.
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/
"It's hard to believe in something you don't understand." -- the sidhi X-files episode
galathaea: prankster, fablist, magician, liar
-
April 7th, 2003, 09:28 PM
#3
ok thanks. What if the user inputs an 09 though will that be recognized as 9?
-
April 8th, 2003, 12:43 AM
#4
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.
*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/
"It's hard to believe in something you don't understand." -- the sidhi X-files episode
galathaea: prankster, fablist, magician, liar
-
April 8th, 2003, 01:09 AM
#5
im doing a simple cin >> month
-
April 8th, 2003, 01:49 AM
#6
Originally posted by dc83
im doing a simple cin >> month
Depends pretty much on current stream flags.
If you want to be absolutely sure,
Code:
#include <iostream>
int main() { int month; std::cin.setf(std::ios_base::dec,std::ios_base::basefield); std::cin >> month; std::cout << month; }
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|