' strtok() sample ' ' Last updated: <2024/02/14 01:51:04 +0900> ' ' C/C++にsplit関数はなく、代わりにstrtok関数を使う|情報科学を学ぶ大学生のブログ ' http://networkprogramming.blog18.fc2.com/blog-entry-89.html ' ' C Standard Library Functions - FreeBASIC Wiki Manual | FBWiki ' https://www.freebasic.net/wiki/ProPgCruntime ' ' Split String Algorithm for FreeBasic - freebasic.net ' https://www.freebasic.net/forum/viewtopic.php?p=294657#p294657 #include "crt.bi" Sub Split(byref text As String, byref delim As String, result() as String) var p = strtok(strptr(text), strptr(delim)) While (p) ReDim preserve result(UBound(result) + 1) result(UBound(result)) = *p p = strtok(NULL, strptr(delim)) Wend End Sub ' main Dim As String text = "this is a test" Dim words() As String split(text, " ", words()) Print text For i As Integer = 0 To UBound(words) Print "[" & words(i) & "]" Next i Print " ...success."