A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Remove All Whitespace in Pascal page! Here, you'll find the source code for this program as well as a description of how the program works.
program RemoveAllWhitespace;
{$mode objfpc}{$H+}
uses
SysUtils;
procedure ShowUsage;
begin
Writeln('Usage: please provide a string');
Halt(1);
end;
function RemoveWhitespace(const S: string): string;
var
builder: TStringBuilder;
ch: char;
begin
builder := TStringBuilder.Create;
try
for ch in S do
case ch of
' ', #9, #10, #13: Continue;
else
builder.Append(ch);
end;
Result := builder.ToString;
finally
builder.Free;
end;
end;
var
Input: string;
Output: string;
begin
if ParamCount <> 1 then
ShowUsage;
Input := ParamStr(1);
if Input = '' then
ShowUsage;
Output := RemoveWhitespace(Input);
Writeln(Output);
end.
Remove All Whitespace in Pascal was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.