用于在字符数组中分隔字符串的 C 函数 [英] C function for separate a string in array of chars
本文介绍了用于在字符数组中分隔字符串的 C 函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个函数来使用 C 中的分隔符来拆分文本.两个参数 text
和 separator
将传递给函数,函数应返回一个 字符数组
.
I want to create a function to split a text using a separator in C.
Two parameters text
and separator
will be passed to the function and the function should return an array of chars
.
例如,如果字符串是Hello Word of C
,分隔符是空格
.
For example if the string is Hello Word of C
and the separator is a white space
.
然后函数应该返回,
0. Hello
1. Word
2. of
3. C
作为字符数组.
有什么建议吗?
推荐答案
strtok 不适合您的需求?
这篇关于用于在字符数组中分隔字符串的 C 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文