CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: compiler error

  1. #1
    Join Date
    Mar 2003
    Posts
    29

    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.

  2. #2
    Join Date
    Sep 2002
    Posts
    1,747
    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

  3. #3
    Join Date
    Mar 2003
    Posts
    29
    ok thanks. What if the user inputs an 09 though will that be recognized as 9?

  4. #4
    Join Date
    Sep 2002
    Posts
    1,747
    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

  5. #5
    Join Date
    Mar 2003
    Posts
    29
    im doing a simple cin >> month

  6. #6
    Join Date
    Feb 2001
    Location
    teh INTARWEB
    Posts
    542
    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
  •  





Click Here to Expand Forum to Full Width

Featured