SAMPLE FILE OUTPUT PROGRAM TO WRITE DATA TO A TEXT FILE
program WRITETEXT (input, output, fdata ); var fdata : TEXT; ch : char; fname : packed array [1..15] of char; begin writeln('Enter a filename for storage of text.'); readln( fname ); rewrite( fdata, fname ); {create a new fdata } readln; {clear input buffer } read( ch ); {read character from keyboard} while ch <> '*' do {stop when an * is typed } begin write( fdata, ch ); {write character to fdata } read( ch ) {read next character } end; write( fdata, '*'); {write an * for end of file } close( fdata ) {close file fdata } end.
writeln( output, 'Hello there. It''s me again'); writeln('The time has come, the Walrus said,'); readln( input, ch ); readln( ch );Click here for answer