Skip to content

Latest commit

 

History

History
30 lines (26 loc) · 530 Bytes

console_stdin.md

File metadata and controls

30 lines (26 loc) · 530 Bytes

program STDIN_EXAMPLE;

{$APPTYPE CONSOLE}

uses Windows, SysUtils, Classes;

var STDIN_HND: Integer; STDIN: THandleStream; text: AnsiString; begin STDIN_HND := GetStdHandle(STD_INPUT_HANDLE); try STDIN := THandleStream.Create(STDIN_HND); try SetLength(text, STDIN.Size); STDIN.ReadBuffer(Pointer(text)^, STDIN.Size); text := StringReplace(text, sLineBreak, '', [rfReplaceAll]); Write(text); finally STDIN.Free; end; finally CloseHandle(STDIN_HND); end;

end.