[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

How do I read words in the reverse order reading from another file?

The Program below Program copies data from one file to another.So the question is, How is how do I read that data in the reverse order and the program should keep record of the maximum sentense used and this should be done using an array.I use a 7.0 Pascal.

Program Copyfiles;

var
   Indata,
   Outdata:text;
   next:char;
   sname,tname:string;

 
begin

write('Enter the name of the source file :');
readln(sname);
write('Enter the name of the the target file :');
readln(tname);
if (sname = tname) then
write('The files are identical, they can''t be copied')
else
begin
Assign(Indata,'a:\source.dat');
Assign(Outdata,'a:\target.dat');
reset(Indata);
rewrite(outdata);
while not eof(Indata) do
begin
read(Indata,next);
write(outdata,next);

end;{while}

close(Indata);
close(Outdata);
writeln('Input file copied to output file, press < Enter > ')
end;
readln
end.

0
ktpule
Asked:
ktpule
1 Solution
 
kotanCommented:
Use recursive method,

..
wc(Indata, outdata, #0);
..

procedure wc(Indata, outdata: text, next: char)
var
  newChar: char;
begin
  if eof(Indata) then
    write(outdata, next)  
  else
  begin
    read(Indata, newChar);
    wc(Indata, outdata, newChar);
    write(outdata, newChar);
  end;

end;
0
 
MoondancerCommented:
You have asked 11 questions at this site and NEVER closed/awarded any of them.  ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.

Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question. Again, please comment to advise the other participants why you wish to do this.

For special handling needs, please post a zero point question in the link below and include the question QID/link(s) that it regards.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Please click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20186611.html
http://www.experts-exchange.com/questions/Q.20188338.html
http://www.experts-exchange.com/questions/Q.20253034.html
http://www.experts-exchange.com/questions/Q.20253103.html
http://www.experts-exchange.com/questions/Q.20253032.html
http://www.experts-exchange.com/questions/Q.20254643.html
http://www.experts-exchange.com/questions/Q.20274803.html
http://www.experts-exchange.com/questions/Q.20275020.html
http://www.experts-exchange.com/questions/Q.20275204.html


To view your locked questions, please click the following link(s) and evaluate the proposed answer.
http://www.experts-exchange.com/questions/Q.20194313.html
http://www.experts-exchange.com/questions/Q.20275908.html

PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange

P.S.  For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.
0
 
NetminderCommented:
Admin notified of User neglect. Force-accepted by
Netminder
CS Moderator
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now