Hello,
I have a simple console application in C++ whose main() does the
following...
char* s = "Hello";
printf("String is %s\n",s);
return 0;
I set a conditoinal breakpoint on the line with the printf, the condition is
s == "Hello".
The breakpoint is not hit and execution continues without stopping at the
breakpoint.
How can i make this happen? Is there something wrong with the condition i
give?
Incidentally when the condition involves an int variable the break point is
hit! Can we not use strings as conditions?
I'm using VS.Net 7.0.9466
Thanks in advance
Vivek
Mike Forkey [MSFT] - 30 Jul 2003 18:41 GMT
--------------------
| From: "bvvarma" <bvvarma@hotmail.com>
| Subject: Conditional Breakpoint not hit! - Need some help
[quoted text clipped - 23 lines]
| Thanks in advance
| Vivek
Correct, you can't use strings the way you are doing it. The equality
operator is not going to work on a string (especially not a char *.) What
you'd need to be able to do is use strcmp() in the BP condition. But
unfortunately, it won't work. This is something we hope to fix in a future
version.
In the meantime, what you need to do to work around this is to test the
value of each character inthe condition:
s[0] == 'H' && s[1] == 'e' && s[2] == 'l' && s[3] == 'l' && s[4]== 'o'
It isn't pretty but it does work.
Mike Forkey
Visual C++ Team
Legal stuff: This posting is provided "AS IS" with no warranties, and
confers no rights. You assume all risk for your use.