Solved

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

Posted on 2002-03-08
3
196 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Android Application not running 1 493
Inno Setup -> Add App Pin to Task Bar 1 725
Convert Jpg /PNG To GIF 5 149
add combobox item based on numbers 9 154
The business world is becoming increasingly integrated with tech. It’s not just for a select few anymore — but what about if you have a small business? It may be easier than you think to integrate technology into your small business, and it’s likely…
This article describes how to reset your Windows 10 password when you've forgotten it.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

809 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