是否有一个与strtol相当于不需要一个空结尾的字符串? [英] Is there a strtol equivalent that does not require a null-terminated string?

查看:141
本文介绍了是否有一个与strtol相当于不需要一个空结尾的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有类似的标准C函数与strtol将采取一个char *和一个非空结尾的字符串的长度?

Is there a standard C function similar to strtol which will take a char* and a length for a non-null-terminated string?

我知道我可以在字符串复制出到一个空结束的地区,但为了提高效率,这是不可取的。

I know that I could copy out the string into a null-terminated region, but for efficiency reasons that is undesirable.

感谢。

推荐答案

在标准库中无此功能。你将不得不使用临时缓冲区方法,或者从头开始编写自己的函数。

No such function in the standard library. You will either have to use the temporary buffer method, or write your own function from scratch.

这篇关于是否有一个与strtol相当于不需要一个空结尾的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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