如何让 atoi() 函数处理字符串
How can I get the atoi() function to work on a string?
int p; long unsigned int z;
while (i <= x.length())
{
const int a = x.length();
char* b;
b = x.substr(sizeof(a) - i, 1);
p = atoi(b);
z = (z + p + 3) * 3;
i++;
}
我得到:
C:UsersAnthonyDownloadspack1.cpp|77|error: cannot convert 'std::basic_string<char>' to 'char*' in assignment|
我试图通过"x"向后向下,并随时写下每个 ascii 代码。底部的公式是一个哈希。"x"是文件名。我稍后会解开它。我需要通过 atoi() 运行它。
请帮忙,因为我不知道该怎么办。 程序中的其他一切都运行良好,但至于这一点,我对这可能是不可能的真实性感到有点不安。请帮忙,谢谢。
int p; long unsigned int z;
while (i <= x.length())
{
const int a = x.length();
string b;
b = x.substr(sizeof(a) - i, 1);
p = atoi(b.c_str());
z = (z + p + 3) * 3;
i++;
}
相关文章:
- 如何在信号处理程序和普通函数中对全局变量进行互斥读写操作
- 如何使用对C函数和类对象的外部调用来处理C++头文件
- std::string 构造函数如何处理固定大小的 char[]?
- 模板函数如何处理可能共享一个交集的多个类型名称?
- 如何编写具有相同名称的相同函数,该函数在C++中几乎以相似的方式处理不同的类参数?
- 为什么这个噪声函数不处理否定参数?
- 传递多处理.将对象值为 ctype 函数?
- 处理简单 cpp 类构造函数中的错误
- 使用返回对象的函数处理错误
- 如何处理没有默认构造函数但在另一个构造函数中构造的对象?
- 在双重继承的情况下如何处理非标准构造函数
- 处理类内的回调时,必须调用对非静态成员函数的引用
- 在线程函数中处理数据向量时进行线程竞速
- 某些 boost::asio 异步函数是否将处理程序连接到操作,以便处理程序被触发一次?
- 如何处理冲突的函数和变量名称?
- 如何在复杂的算法中处理goto函数?
- 如何让 atoi() 函数处理字符串
- 生产编译器如何在流控制上实现析构函数处理
- 使用 lambda 函数处理 C++ libsigc++ 信号
- 为数组创建c++ max函数:处理数组大小为0的情况的正确方法是什么?