C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 07-18-2003, 09:19 PM   #1
Registered User
 
Bad_Scooter's Avatar
 
Join Date: Mar 2003
Posts: 15
How can I read one number at a time?

How can I read in one number at a time from a string of numbers?
Something like this:

1429943983...

I want to read in the one, then the four, and so on. My first thought was to use get. Something like fin.get(number); But this statement only seems to accept a char, not an int. I am at a loss, short of reading in a char and converting to an int through 10 if statements. Any help would be great.
Bad_Scooter is offline   Reply With Quote
Old 07-18-2003, 09:35 PM   #2
+++ OK NO CARRIER
 
quzah's Avatar
 
Join Date: Oct 2001
Posts: 10,628
Do that. Read a character, convert it to a number. Subtract the character value of zero from the character number to get its numeric value. Example:

cout << "'4' - '0' = " << '4' - '0' << endl;

Enjoy.

Quzah.
__________________
Hundreds of thousands of dipshits can't be wrong.


Are you up for the suck?
quzah is offline   Reply With Quote
Old 07-18-2003, 09:58 PM   #3
Registered User
 
Bad_Scooter's Avatar
 
Join Date: Mar 2003
Posts: 15
Thanks, that's what I'll do, I just thought there may have been an easier way.
Bad_Scooter is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Read until negative number m_user C Programming 10 04-03-2009 06:38 AM
Number Guessing blacknapalm C Programming 2 10-01-2008 01:48 AM
Read and set\change system time Hexxx C++ Programming 9 01-02-2006 07:11 AM
how to read hard disk serial number toufiq_raja C Programming 4 08-18-2005 10:08 PM
airport Log program using 3D linked List : problem reading from file gemini_shooter C Programming 3 03-04-2005 02:46 PM


All times are GMT -6. The time now is 02:28 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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