Page 1 of 1

In simple words "modifying a text line"

Posted: Thu Aug 18, 2005 1:53 pm
by cryptid
ok my earlier post did not return any results so i am posting question again in a more simple manner

Want to Make a program that will read a Text file and will add few words in the begging of the lines in the text file as well as in the ending of the line

Say the text file "file.txt" has the line
=====file.txt======
hi i need help
please help me
===============
the program should read this file and change it to

=====file.txt======
abc hi i need help def
abc please help me def
===============

so how can this be done please help

Posted: Thu Aug 18, 2005 1:59 pm
by Z!re
[Pseudo code]
open file 1 for input
open file 2 for output

do
read line from file 1
line = "abc" + line + "def"

print line to file 2

loop until end of file 1
close both files

remove file 1

rename file 2 to file 1
[/pseudo code]
What part of the program dont you understand?
Is it a command you're looking for?
Is this homework?
What have you done so far?