?
Solved

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

Posted on 2002-03-08
3
Medium Priority
?
214 Views
Last Modified: 2010-04-16
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
Comment
Question by:ktpule
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 6

Accepted Solution

by:
kotan earned 400 total points
ID: 6850067
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
 
LVL 1

Expert Comment

by:Moondancer
ID: 6858499
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
 
LVL 5

Expert Comment

by:Netminder
ID: 6905980
Admin notified of User neglect. Force-accepted by
Netminder
CS Moderator
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The well known Cerber ransomware continues to spread this summer through spear phishing email campaigns targeting enterprises. Learn how it easily bypasses traditional defenses - and what you can do to protect your data.
Introducing Priority Question, our latest feature.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month14 days, 8 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question