menu prev next

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.


SELF TEST
Determine what the following code statements do

	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


Copyright B Brown/P Henry/CIT, 1988-1997. All rights reserved.
menu prev next

1