strlen

Plain Text

Public Domain

Determine the length of a NUL-terminated character string in Forth

Download (right click, save as, rename as appropriate)

Embed

1
2
3
4
5
: strlen ( addr -- n )
 dup 1 chars -
 begin char+ dup c@ 0= until
 swap -
 ;