Thread: Reading text as int

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    35

    Reading text as int

    How could I read a text file and then find the numbers in it and convert them to int? Or is there a way to read them in as ints with out conversion? Thanks...
    you make me rery ascared

  2. #2
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    if you are using streams....

    int in;
    stream >> in;

    if not, look up the atoi() function.

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    161
    open & check each character one by one. If a character is from '1' to '9' or '0' then load it up to memory until you come across to an invalid number e.g. letter or space. to convert it to int use atoi(), itoa does the reverce.

    Hope that helps!

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    35
    Thank you!
    you make me rery ascared

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to combine these working parts??
    By transgalactic2 in forum C Programming
    Replies: 0
    Last Post: 02-01-2009, 08:19 AM
  2. Converted from Dev-C++ 4 to Dev-C++ 5
    By Wraithan in forum C++ Programming
    Replies: 8
    Last Post: 12-03-2005, 07:45 AM
  3. Switch/case Problems (long code in post)
    By Wraithan in forum C++ Programming
    Replies: 2
    Last Post: 12-01-2005, 06:40 PM
  4. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 05:20 AM
  5. Replies: 4
    Last Post: 11-23-2003, 07:15 AM