file i/o

This is a discussion on file i/o within the C++ Programming forums, part of the General Programming Boards category; When i read in from an input file how do i know if a word in that file ends with ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    20

    file i/o

    When i read in from an input file how do i know if a word in that file ends with an s.

    And what if I have to change the word shoe to sock everytime the word shoe is in the file. How would i do this

    thanks

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    What do you have so far?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    20
    I haven't started the program yet I am trying to decide what all i need to do before I begin.

  4. #4
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Here's a start:
    Code:
    using namespace std;
    ifstream fin("in.dat");
    
    string input;
    while (getline(fin, input))
    {
         if (input == "shoe")
             // Do something
    }
    
    fin.close();
    Hope this helps.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  3. 2 questions surrounding an I/O file
    By Guti14 in forum C Programming
    Replies: 2
    Last Post: 08-31-2004, 12:21 AM
  4. File I/O problems!!! Help!!!
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 05-17-2002, 09:09 PM
  5. advice on file i/o
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-29-2001, 05:56 AM

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