c - 我的双指针表没有完全返回。我的功能是假设用字符集拆分字符串
问题描述
char **ft_split(char *str, char *charset)
{
int i = 0;
int index = 0;
int len;
if (condition(str[0], charset) != 1)
while (condition(str[index], charset) != 1)
index++;
while (condition(str[index], charset) == 1)
index++;
int tab = nbword(str, charset);
printf("%d, len\n\n", tab);
char **tableau = malloc((tab + 1) * sizeof(char));
while (str[index] != '\0')
{
while (condition(str[index], charset) == 1)
index++;
len = wordlen(str, index, charset);
tableau[i++] = malloc(len + 1 * sizeof(char));
ft_strSPcpy(tableau[i - 1], str, len - 1, index);
printf("tableau[%d] = %s\n", i - 1, tableau[i - 1]);
index += len;
}
tableau[i] = 0;
return tableau;
free(tableau);
}
这就是东西阻塞的地方。
在主要之前
tableau[0] = bodeg
tableau[1] = c vr
tableau[2] = iment
tableau[3] = uper
in function main
tableau[0] = tableau[last] = (null)
c vr
iment
uper
这就是我在执行时得到的。
如您所见,在主函数中,第一个字符串为空?发生什么事了 ?
在我最后一段时间之后,我也试着看看,所有的弦都很好。
谢谢你
解决方案
推荐阅读
- r - 在 DT 中带有 rows_selected 的 rbind()
- r - 使用最普遍的列值交换 data.table 列
- module - Http post方法关键意义
- c# - 如何使用 c# 发送没有 ATT00001.bin 文件的嵌入式图像电子邮件
- arrays - MVC 自定义验证字符串数组客户端
- hashmap - 如何遍历包含 Arraylist 的 HashMap
- r - 基于列和 rbind 匹配合并数据帧
- c# - 如何将字符串(带有 scape 字符的 json)转换为动态对象?
- liferay - 如何在 liferay 的自定义主题中插入很棒的字体?
- c++ - 模板函数中的 C++ 初始化 - 新的 Initializer 表达式列表被视为复合表达式