Thread: Check certain positions of an int?

  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    36

    Check certain positions of an int?

    This is possibly a very basic question, but how to check the second or third value of of an int variable? Am I supposed to use on of them string functions or is there a simpler way?

  2. #2
    Webhead Spidey's Avatar
    Join Date
    Jul 2009
    Posts
    285
    What do you mean by sting functions on an int ?
    Also, yes getting the third or fourth position is as simple as reaching the third or fourth digit which you should know how to do from math class.
    Spidey out!

  3. #3
    Registered User
    Join Date
    Jul 2009
    Posts
    36
    I am trying to write a function that checks certain positions of an int and the value of it. I would like to know how to do this. And what do you mean with math class?

  4. #4
    Webhead Spidey's Avatar
    Join Date
    Jul 2009
    Posts
    285
    What I meant was that there is a simple formula to get each digit of an int. Think about it, its pretty easy actually.

    Supposing your number was 100
    then the hundredths place digit is 1
    and the tenths place digit is 0
    and the digit at the ones place is 0

    Now how would you write a program to do that ?
    Spidey out!

  5. #5
    Registered User
    Join Date
    Jul 2009
    Posts
    36
    Ok got it, Modulus did the trick. thx for the wink in the right direction.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Working with random like dice
    By SebastionV3 in forum C++ Programming
    Replies: 10
    Last Post: 05-26-2006, 09:16 PM
  3. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 05:20 AM
  4. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM
  5. A Simple (?) Problem
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 10-12-2001, 04:28 AM