-
May 6th, 2009, 05:59 AM
#1
Insert text to a file?
Hello, all!
How can I print some text into a .txt or .bat file?
I use C++ with Virsual Studio 2008. I tryed on Google, those results in there didn't help...
- realchamp.
-
May 6th, 2009, 07:18 AM
#2
Re: Insert text to a file?
Here is an algorithm:
1. Open a new file
2. Copy the content of the old file into the new file up to the place where you want to insert your text
3. Write your text to the new file
4. Copy the rest of the old file to the new file
5. Close the new file
6. Remove the old file
7. Rename the new file with the name of the old file
Another algorithm is possible if the file is smaller than your available memory:
1. Read the entire file into memory
2. Write data from memory up to the place where you want to insert your text
3. Write your text
4. Write the end of your data from memory
-
May 6th, 2009, 09:10 AM
#3
Re: Insert text to a file?
-
May 6th, 2009, 11:02 AM
#4
Re: Insert text to a file?
Originally Posted by Mybowlcut
Not like that. But I had some of the same pages.
-
May 7th, 2009, 04:02 AM
#5
Re: Insert text to a file?
It's very convenient to become familiar with what terms to use. Good books will better your terminology.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|