Answer the question
In order to leave comments, you need to log in
Why doesn't a compiled pascal program run without a shell?
I'm teaching my friend Pascal, and he wants his application to work separately from the shell.
I did everything I needed and set saving the exe file to a separate folder I
run the file, it loops and after that the program ends, although there are a couple more lines of code
However, if you run it through the shell, the program works properly
I can’t understand what the problem is!
var otvet,ans,attempts:integer;
begin
otvet:=random(100);
writeln('Привет,это игра "Угадай число",правила просты.');
writeln('Отгадай число загаданное,мной,ВЕЛИЧАЙШЕЙ В МИРЕ ПЕКАРНЕЙ ВСЕЯ РУСИ.');
readln(ans);
while(ans <> otvet) do
begin
attempts:=attempts+1;
if(ans < otvet) then begin writeln('Мое число больше!'); ans := otvet; readln(ans); end
else if(ans > otvet) then begin writeln('Мое число меньше!'); ans := otvet; readln(ans); end
end;
writeln('Молодец, ты меня победил!');
writeln('Твое количество попыток: '+ attempts);
end.
Answer the question
In order to leave comments, you need to log in
The output to the screen is made in a text window (console mode), while the last text just skips a glimpse, the program ends and the text window closes immediately.
Therefore, you need to run the executable either using cmd.exe, or in a Pascal program by adding the last line ReadLn;
, re-compiling it into an executable. In the latter case, the program will wait for Enter to be pressed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question