Thread: File i/o... integers

  1. #1
    Registered User Gnoober's Avatar
    Join Date
    Oct 2002
    Posts
    40

    File i/o... integers

    I need to know how to read a number in a text file as an integer, not a string. The number is on its own line which makes it easier I'm sure, but getline() takes a "char" as an argument. I have tried Google and the board search to try and find my answer but haven't. Thanks for any help!
    - Grady (:

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Code:
    int MyInt;
    ifstream ReadFile;
    ReadFIle.open(...);
    
    ...
    
    ReadFile >> MyInt;
    
    ...
    
    ReadFile.close();
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User Gnoober's Avatar
    Join Date
    Oct 2002
    Posts
    40
    Geez, I feel like an idiot... Thanks Magos!
    - Grady (:

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Subtle(?) File I/O Problem
    By cecomp64 in forum C Programming
    Replies: 9
    Last Post: 07-16-2008, 11:39 AM
  2. File I/O Question
    By Achy in forum C Programming
    Replies: 2
    Last Post: 11-18-2005, 12:09 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. File I/O problems!!! Help!!!
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 05-17-2002, 08:09 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM