Question about file

This is a discussion on Question about file within the C++ Programming forums, part of the General Programming Boards category; hi i have a file with this text in it : "hi , how are you? are you ok?" i ...

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    17

    Question about file

    hi
    i have a file with this text in it : "hi , how are you? are you ok?"
    i want add a word like TODAY after "are" without lose other words.

    how can do it?
    i do not want use temp file.
    Last edited by aminpost; 12-01-2009 at 11:11 AM.

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    read contents of the file into string, modify string, write string back to file
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered User
    Join Date
    Dec 2008
    Posts
    17
    Quote Originally Posted by vart View Post
    read contents of the file into string, modify string, write string back to file
    how modify string?

  4. #4
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Code:
    std::string test = "a";
    
    test += "b";
    like this?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  5. #5
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,806
    Probably you'd want to use the insert member function to insert the word you wish to add to the string once you find where in the string the insert is to take place.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 11:39 PM
  2. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 05:54 PM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 09:39 AM
  4. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 04:39 AM
  5. Replies: 3
    Last Post: 03-04-2005, 02:46 PM

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