Thread: Validate a user input integer?

  1. #16
    Registered User
    Join Date
    Dec 2003
    Posts
    56
    I really did, once again thank you.

  2. #17
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,090
    Originally posted by alphaoide
    No, problem. We enjoyed it. That's how we learn from one another. Hope you learn something, too.
    Most definitely!

  3. #18
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >didn't mean to start an entire war on whether or not to use int or string...
    What fun would these forums be without well thought out arguments?
    My best code is written with the delete key.

  4. #19
    Registered User
    Join Date
    Dec 2003
    Posts
    56
    oops, one more question... is 112 the only 3 digit that works, and there must be some four digits that work too... Not that it really matters I suppose, but since the data in the arrays that will be storing the ISBNs are already ints and cannot be changed I am going to use an integer scheme as opposed to a string conversion, and since we really haven't learned anything about string to int conversion or vice versa I don't think that is what is being looked for. I appreciate all the help...

  5. #20
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,090
    Actually, any combination of numbers works for the first four digits, right? You just have to take the sum of them modulus 9 and use that as the last digit. So I would guess there are 10 possible 2 digit ISBN's (00000, 00011, 00022, 00033, ... 00090), 90 possible 3 digits ISBN's (00101, 00112, 00123, ... 00202, ... 00990), and so on and so forth. That would make about 1000 valid ISBN's with at least one leading zero.

    But of course you are right, it doesn't really matter. It only mattered in the case of Shakti's and Prelude's original code suggestions because they checked to make sure that there were no leading zeros in the 5 digit number. You don't have to include that check in your code (although I'd advise at least a check that the integer is not more than 5 digits).

  6. #21
    Registered User
    Join Date
    Dec 2003
    Posts
    56
    i see. thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. Assignment HELP!!
    By cprogrammer22 in forum C Programming
    Replies: 35
    Last Post: 01-24-2009, 02:24 PM
  3. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 09:42 AM
  4. Replies: 4
    Last Post: 04-03-2008, 09:07 PM
  5. ~ User Input script help~
    By indy in forum C Programming
    Replies: 4
    Last Post: 12-02-2003, 06:01 AM