令牌功能在字符串类中 [英] Token function in a string class

查看:72
本文介绍了令牌功能在字符串类中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Theres类的这个函数



void split(char token,String *&,int& ntokens);



它应该根据给定的标记拆分字符串并将所有子串存储在作为第二个参数传递的动态数组中,并在第三个参数中返回ntokens。



不幸的是,我既不理解问题的描述,也不理解函数的参数。帮助将不胜感激。



注意:我们不允许使用cstring函数。



我尝试了什么:



我不明白这个问题,因此,没试过。

Theres this function of a String class

void split(char token, String *&, int &ntokens);

And it should should split the string according to given token and store all substrings in a dynamic array passed as second argument, and return ntokens in third argument.

Unfortunately, I don't understand the problem neither the description given as well as well as the arguments of the function. Help would be appreciated.

Note: We are not allowed to use cstring functions.

What I have tried:

I don't understand the problem, therefore, haven't tried it.

推荐答案

您可以使用 strtok 开始实现您的功能[ ^ ]或编译器的任何适当版本,例如: strtok_s



函数参考页面底部有示例,可能有助于您了解如何使用它
you can begin implementing your function with strtok[^] or any appropriate version to your compiler , eg : strtok_s

There is sample at the bottom of function reference page , that might help you to understand how to use it


这篇关于令牌功能在字符串类中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆