Solved

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

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pascal -- How do I use the variables of a procedure in another? 4 692
change the mouse cursor 1 999
FMXGrid getting check box state 5 514
find a node in VST 2 68
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Binary Differential Replication, What it is, how it works and how it differs from standard delta file replication
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

816 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

11 Experts available now in Live!

Get 1:1 Help Now