将字符串值00与int值0(不是1)进行比较
Comparing a string value of 00 to an int value of 0 not 1
我有一个值为00
的字符数组charArray
。CCD_ 3产生1而不是0。我想把00转换成0。
以下操作很好。http://ideone.com/dpTMQq
#include <stdlib.h>
#include <assert.h>
int main( void ) {
char charArray[] = "00";
int intValue = atoi( charArray );
assert( intValue == 0 );
}
相关文章:
- 检查输入是否不是整数或数字
- 有充分的理由在h文件中使用include保护而不是cpp文件吗
- 比较两个 constexpr 指针不是 constexpr?
- 隐式转换为比较函数对象(函子)用于 std::sort 而不是 std::map?
- CPP unordered_set只使用比较器而不是哈希
- 关联容器,比较函数不是元素类型的一部分吗?
- For 循环仅比较数组的第一部分而不是整个数组
- AVX2浮子比较并获得0.0或1.0,而不是all-0或全零件
- 可以错误地使用赋值运算符而不是比较运算符的地方,= Vs ==
- 为什么在浮点比较中,最后一个小数位数为5的浮点值能给出正确的输出,而在其他情况下却不是
- 互锁。比较交换<Int> 使用大于或小于而不是相等
- 如何比较类的数据成员的名称而不是它们的值
- 为什么 std::sort 有两个实现(带和不带比较器),而不是一个带有默认模板参数的实现
- 在 C++ STL 的比较函数中使用"<="符号而不是"<"符号有什么区别?
- 是不是比较意味着一个分支
- 为什么C++ STL 容器使用 "less than" 运算符<而不是 "equal equal" 运算符== 作为比较器?
- 如果比较函数不是运算符<,为什么std::sort会崩溃;
- 为什么比较 constexpr 函数的两个参数不是静态断言的常量条件
- 将字符串值00与int值0(不是1)进行比较
- 为std::map定义一个比较函数,它使用值而不是键