KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q67360: CodeView Does Not Debug kbhit() Correctly

Article: Q67360
Product(s): See article
Version(s): 3.00 3.10 3.11  | 3.00 3.10 3.11
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | buglist3.00 buglist3.10 buglist3.11 | mspl13_basic
Last Modified: 4-DEC-1990

When setting a breakpoint between the kbhit() function and a function
to read a character from the input stream, CodeView will grab the
character from the input stream when the breakpoint is executed.

The following code example demonstrates the problem. If a breakpoint
is placed on the line containing the getch() function, the character
input from the keyboard will be placed in CodeView before the getch()
function is actually stepped over. You will not be prompted for the
character when you step over the getch() function. The character you
typed to stop the kbhit() loop will be used for the getch() function
call when that line is executed.

Microsoft has confirmed this to be a problem in CodeView versions
3.00, 3.10, and 3.11. We are researching this problem and will post
new information as it becomes available.

Sample Code
-----------

#include <stdio.h>
#include <conio.h>

void main(void)
{
        int a;

        do {
                printf(".");
        } while(!kbhit());

        a = getch();         // put breakpoint here

        printf("%c\n", a);
}






Microsoft Linker
=============================================================================

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.