while循环保持打印和重复,我的getch出了什么问题?

时间:2017-12-17 19:20:31

标签: c while-loop getch

我试图在输入y / n后使循环停止,但它只是返回打印并要求一个字符。这有什么不对?

代码:

 <?php
    while (have_posts()) : the_post();

        get_template_part('template-parts/content', 'page');
        do_action('flash_before_comment_template');

        // If comments are open or we have at least one comment, load up the comment template.
        if (comments_open() || get_comments_number()) :
            comments_template();
        endif;

        do_action('flash_after_comment_template');

    endwhile; // End of the loop.
    ?>

1 个答案:

答案 0 :(得分:1)

注意你的状况;这两个条件中的一个始终为真,因此while条件始终为真。

将其更改为:

while (con != 'n' && con != 'y')