我的任务是从 char[]
的一部分获取 long
数值,其中我有其开始和结束的索引。我刚刚学习 C,所以我很困惑哪个函数最适合我的情况..
可以说我正在制作函数getNum()
:
static char words[100000]; //lets say this is string filled with many num. values and other stuff.
long getNum(int begin, int end){
return (long){part of string starting at words[begin] and ending at words[end]}
}
我想知道最好的方法和最简单的方法来做到这一点。任何其他评论也非常感谢。
最佳答案
我们给出算法,你编写代码。同意吗?
好的,所以逻辑应该是
关于C 从字符串的一部分获取数值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30458067/