Solved

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

Posted on 2002-03-08
3
186 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
3 Comments
 
LVL 6

Accepted Solution

by:
kotan earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Admin notified of User neglect. Force-accepted by
Netminder
CS Moderator
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the fileā€¦
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now