循环导致无法访问的断点
Loop causing unreachable breakpoints
我正试图在C++中复制Luhn算法,但遇到了一个问题。正如你所看到的,我有两个for循环。在MSVC中,如果我在第二个for循环中放置一个断点,或者甚至在返回时,MSVC会告诉我断点不会被击中。
是什么导致了这个问题?
int luhn_checksum(std::vector<int> cardnumber[NUMBER_OF_DIGITS - 1]) {
//step 1: duouble every second number
for (int i = 1; i < NUMBER_OF_DIGITS; i + 2) {
new_digits[i] = digits[i] * 2;
if (new_digits[i] > 9) {
//if the product is larger than 9 we will add the two numbers together
//example: 9 * 2 = 18 so we will add 1 + 8 to get 9
tmp1 += new_digits[i] % 10;
new_digits[i] /= 10;
tmp1 = 0;
}
}
//step 2: sum all the values
for (int i = 0; i < NUMBER_OF_DIGITS; ++i) {
checksum += new_digits[i];
}
return checksum;
}
在第一个for循环中,您没有增量所以更换
for (int i = 1; i < NUMBER_OF_DIGITS; i += 2)
如果您想增加2
相关文章:
- 通过方法访问结构
- 使用不带参数的函数访问结构元素
- 如果我只是不访问queue_front节点的子节点,而是将它们推到队列中呢?还是BFS吗
- 用于访问容器<T>数据成员的正确 API
- 访问者访问变体并返回不同类型时出错
- 尝试通过多个向量访问变量时,向量下标超出范围
- 无法访问嵌套类.类的使用无效
- 写入位置0x0000000C时发生访问冲突
- 我们可以访问一个不存在的联盟的成员吗
- C++从另一个类访问公共静态向量的正确方法是什么
- 我的简单if-else语句是如何无法访问的代码
- 从C++dll访问C#中的一行主要参数
- 概念TS检查忽略私有访问修饰符
- 访问被拒绝后,c++中的故障保护代码
- 在c++中访问int到类对象的映射时出错
- 循环导致无法访问的断点
- 访问违反错误后,VS2008 c++断点永久不活动(没有与行相关的可执行代码)
- 为访问冲突定义条件断点
- 在添加断点并运行程序时,无法访问地址处的内存
- 重新设置断点时出现GDB错误(无法访问内存)