該方法返回特定字符串的長度
len(str)
str ?這是需要確定字符數(shù)的字符串。
返回值是字符串中的字符數(shù)。
-module(helloworld).
-import(string,[len/1]).
-export([start/0]).
start() ->
Str1 = "This is a string1",
Len1 = len(Str1),
io:fwrite("~p~n",[Len1]).當我們運行上面的程序時,我們將得到以下結果。
17