CRT Strtok Function

This program demonstrates the CRT Strtok function.

'CRT Strtok
'Demonstrates the CRT strtok function.

#include once ""

Dim As String tstr, tmpstr, delim
Dim zret As Zstring Ptr

'Create delimiters
delim = " ,!-"
'Create parse string
tstr = "Hello-World, From Freebasic!"
'Create a working copy of string
'strtok will alter original string
tmpstr = tstr
'First call with string and delimiters
zret = strtok(tmpstr, delim)
'Check for a NULL pointer
If zret <> NULL Then
    Print zret[0]
    'Parse rest of string
        'Call with NULL to work on same string
        zret = strtok(NULL, delim)
        If zret <> NULL Then
            Print zret[0]
        End If
    Loop Until zret = NULL
End If