您的位置:首页 > 其它

freeswitch函数之switch_separate_string字符串分割

2017-01-07 15:47 393 查看
switch_separate_string

switch_separate_string_string(char *buf, char *delim, _Post_count_(return) char **array, unsigned int arraylen);

完成split的功能

使用示例:

char *params = "param_1=p1,param_2=p2,param_3=p3";

//要获取到每一个param,就要将params用逗号分割
char *param_tmp = strdup(params);

char *param_array[10] = { 0 };

int p_index = 0;

int param_size = switch_separate_string(param_tmp ,',',param_array,(sizeof(param_array) / sizeof(param_array[0])));

for(p_index = 0; p_index < param_size; p_index ++)
{
switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_NOTICE,"---[%s]---\n",param_array[p_index]);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: