KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q40494: Watching Pointers in QuickC Debugger

Article: Q40494
Product(s): See article
Version(s): 1.00 1.01 2.00
Operating System(s): MS-DOS
Keyword(s): ENDUSER | | mspl13_c
Last Modified: 20-JAN-1989

The QuickC debugger makes a distinction between pointers of type CHAR
and all other types. The debugger will assume that any "char *"
pointer will contain the address of a Null terminated string.

The impact of this assumption can be seen when setting a WATCH VALUE
on a specified pointer. If the pointer is declared as "char *", then
the debugger displays the WATCH value as the string that is pointed to
by the pointer. If the pointer is declared as any type other than
"char *", then the WATCH value displays the address of the variable
and not the value of the variable.

The following code fragments illustrate this distinction:

char *CHptr = "Faust liebt Gretchen" ;
int  *INTptr= "Faust liebt Gretchen" ;

A WATCH set on CHptr displays the following:

   "Faust liebt Gretchen"

A WATCH set on INTptr displays the address of the string and not the
string itself:

   'Faust liebt Gretchen'

If you want to WATCH the string pointed to by INTptr, do the
following:

1. Pull down the DEBUG menu.

2. Choose the WATCH VALUE selection.

3. Type "(char *)INTptr".

Casting INTptr to "char *" type displays the character string.

If you want to WATCH the address of the string to which CHptr points,
do the following:

1. Pull down the DEBUG menu.

2. Choose WATCH VALUE.

3. Type "(int *)CHptr".

Casting CHptr to a type other than "char *" (such as "int *")
displays the address of the string to which CHptr points.

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.