Kamailio 整数转字符串
链接在这里:
https://lists.kamailio.org/mailman3/hyperkitty/list/sr-users@lists.kamailio.org/thread/ZXPV4JKVBYHC2BW6H5NOWPIAOVFAVIQN/
问要怎样把整数转成字符串
其实 core 讲的很清楚
Comparison operations between two strings are done using strcmp(s1, s2) and it is considered:
s1 < s2 - if the result of strcmp(s1, s2) is negative
s1 == s2 - if the result of strcmp(s1, s2) is 0
s1 > s2 - if the result of strcmp(s1, s2) is positive
Operations between two values with different types are done by converting the second value (right operand) to the type of the first value (left operand).
Examples:
1 + "20" -> converted to: 1 + 20 (result: 21)
"1" + 20 -> converted to: "1" + "20" (result: "120")
4 > "20" -> converted to: 4 > 20 (result: false)
"4" > 20 -> converted to: "4" > "20" (result: true)
两个字符串之间的比较操作通过strcmp(s1, s2)完成,其比较规则如下:
若
strcmp(s1, s2)的结果为负数,则s1 < s2若
strcmp(s1, s2)的结果为 0,则s1 == s2若
strcmp(s1, s2)的结果为正数,则s1 > s2
对于不同类型的两个值之间的运算,会将第二个值(右操作数)转换为第一个值(左操作数)的类型。
示例:
1 + "20"→ 转换为:1 + 20(结果:21)"1" + 20→ 转换为:"1" + "20"(结果:"120")4 > "20"→ 转换为:4 > 20(结果:false)"4" > 20→ 转换为:"4" > "20"(结果:true)
