简体   繁体   English

调试不进入循环

[英]debugg not going inside the loop

I am practicing on chars and i wrote a while loop that ends whenver i see a ";"我正在练习字符,我写了一个 while 循环,当我看到一个“;”时结束

however when i am trying to debug it doesnt go inside the loop only at the last loop and I dont understand why但是,当我尝试调试它时,它不会 go 仅在最后一个循环中循环内,我不明白为什么

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

    void main()
{
    char str[] = "abccc;";
    int i = 0;
    while (str[i] != ';') 
    {
        i++;
        printf("%d \n",i);
    }

}

thats the code, it works and realy simple but if I debugg to see it only goes inside the loop in the last time I am not sure why and how to fix这就是代码,它可以工作并且非常简单,但是如果我调试它只在最后一次进入循环内部,我不知道为什么以及如何修复

I would suggest keep tracing even if it looks like its not going inside the loop.我建议继续跟踪,即使它看起来没有进入循环。 Sometimes the way the code is generated, the execution in the debugger is not linear.有时代码的生成方式,在调试器中的执行不是线性的。 In fact as you keep tracing, keep a watch for output of the printf from the program.事实上,当您继续跟踪时,请留意程序中 printf 的 output。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM