Input Function

This is a discussion on Input Function within the C++ Programming forums, part of the General Programming Boards category; I need a way to read input 1 number at a time from a string of 500-1000 numbers. cin would ...

  1. #1
    Unregistered
    Guest

    Input Function

    I need a way to read input 1 number at a time from a string of 500-1000 numbers.

    cin would just give me the entire string, so what do I use?

  2. #2
    Registered User kitten's Avatar
    Join Date
    Aug 2001
    Posts
    109
    Use cin to input whole string and then index it to handle one number at time. You can access the individual number Str[0], Str[1], and so on...
    Making error is human, but for messing things thoroughly it takes a computer

  3. #3
    Registered User Strider's Avatar
    Join Date
    Aug 2001
    Posts
    149
    I assume you are looking to read in 10 base numbers and not binary. If this is correct, then how is the "string" organized? Is there a defined separator? Are they all just bunched together(no spaces)? If so, are you just looking for the range of 0 to 9? If not, how do you intend to separate the individual numbers?

    My best guess on this would be to read in the string of numbers as an array of char's and then convert them to int's and place them in an int array using a loop based on the total count. Maybe clarify your need, let me know if this plan of action will work for you, and I can help you get started.

    David
    One Ring to rule them all, One Ring to find them,
    One Ring to bring them all and in the darkness bind them
    In the Land of Mordor where the Shadows lie.

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    154
    I believe cin.get would work, assuming no whitespace between characters.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 07:54 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 12:45 PM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  4. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 02:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21