Return to Snippet

Revision: 65524
at December 12, 2013 13:31 by MalcolmX86


Initial Code
{Zouhair2.pas}
    Var
     S:String;
     l:Byte Absolute S;
     m,c:byte;
     
    Label lp;
     
    Begin
     WriteLn('enter your string below this line then press the enter key');
     Readln(S);
     lp:
      if S[l] in [' ','.',',',':',';']
       then c:=0 else Begin inc(c); if m<c then m:=c; End;
      Dec(l); if l>0 then goto lp;
     WriteLn(m,' characters is the length of the longest word in that string');
    End.

Initial URL
pastebin.ca/2496436

Initial Description
I compiled this 16 line program with freepascal , and it was 23K ! Zouhair Tele asked :
Count the number of words in a given string. Word is a sequence of characters separated by spaces or punctuation marks (dot, comma, semicolon, colon).
For example: the string “abc d, efg,..hijkl.mno” - 5
Working with Strings
please can you help me with this

Initial Title
Longest Word in String - 16 lines source = Whopping 23K Executable!

Initial Tags


Initial Language
Pascal