I did a program in which you type a string and it appends that string to a file. This goes on a repeat loop until the user enters "end". I have declared an if loop. If the variable gets "end" then the loop stops. This happens correctly. The problem is that the word "end" get added to the file as well
x:=0;
repeat
writeln('Enter game. Enter "end" to stop');
readln(game);
if game <> 'end' then
x := x + 1 ;
writeln(filevar,' ',game);
until game = 'end' ;
close(filevar);
Shouldn't the program skip the "If" part as game = 'end' ?
Aucun commentaire:
Enregistrer un commentaire