Computer Science Canada

Text file program

Author:  Paul [ Sun Feb 29, 2004 9:51 am ]
Post subject:  Text file program

This is a school assignment, we just learned how to work with getting info and outputting into text files and stuff. I wasn't paying alot of attention. This program basically gets info from one text file, and puts the info into 3 different files according to the info there. Since I wasn't paying attention, is there anyway to shorten this significantly?

Author:  Delos [ Sun Feb 29, 2004 11:33 am ]
Post subject: 

Looks good.

How about a little commenting?

For the sake of completeness, you should close your filestreams at the end of the programme.

In this particular prog, it makes no difference, but once you get to longer progs with more files, it is really useful to close any unnecassary streams...

Author:  recneps [ Sun Feb 29, 2004 11:37 am ]
Post subject: 

Thats about as short as i could get it, but im sure others here will compete to have the least lines Smile

Author:  Paul [ Sun Feb 29, 2004 12:48 pm ]
Post subject: 

Delos wrote:

For the sake of completeness, you should close your filestreams at the end of the programme.

You mean like this?

close (input)
close (output)
close (output1)
close (output2)

ok, though I dunno what it does

Author:  BlAcK TuRtLe [ Sun Feb 29, 2004 3:13 pm ]
Post subject: 

My class never learned reading and writing in turing in Gr 10 but we learned it in Java in Gr.11. Just wondering if it runs under the same principle.

Author:  shorthair [ Sun Feb 29, 2004 3:40 pm ]
Post subject: 

if you leave them oppen ,you slow down your programs and you keep them in use , becuase turing keeps it in its cache or in memory ( or somthing i believe ) bcause the stream is still open so it has to keep watching that stream , if you close it after its been written to turing dosent have to worry about it anymore


: