0

I have this breakpoint condition:

strcmp(word, "circle") == 0

But it doesn't seem to work. How do we use conditional breakpoints with strings in Clion and how do I get this condition to work as intended. I can't show my code as it's for a university assignment.

Edit: My program reads input from a collection of files and creates an inverted index based on occurrences of the word in the file. So obviously I don't want to resume program 100 times to get to the word 100th word (100th iteration of my while loop).

  • "it doesn't seem to work", please elaborate. Maybe according to [ask]. – Yunnosch Mar 18 '22 at 16:10
  • Maybe you and I understand "breakpoint condition" differently. You are using a debugger on your program. On some line of code you place a break point which you expect to only trigger and stop the execution when the condition applies that the content of some `word` (more info needed there; type, size, linking attributes....) compares as identical to "circle"). True? And then it does not do so in some unspecified way.... Breaks always? Breaks never? Breaks when you consider `word` non-identical? – Yunnosch Mar 18 '22 at 16:14
  • Are you sure you can use function calls (like `strcmp`) in a breakpoint condition? – Jabberwocky Mar 18 '22 at 16:23
  • Can you print `strcmp(word, "circle")` from the debugger when you are stopped at a breakpoint? – n. m. could be an AI Mar 18 '22 at 16:26
  • when I say doesn't seem to work I mean it applies the breakpoint as if the breakpoint condition isn't there. The condition does nothing to the breakpoint – Kerelos Tawfik Mar 18 '22 at 16:51
  • Read the edit guys – Kerelos Tawfik Mar 18 '22 at 16:54

1 Answers1

0

Clion uses LLDB by default.
See this SO answer: https://stackoverflow.com/a/37221936/3353857

(int) strcmp("test", var) == 0

I think the "(int)" cast might do the magic.

caoanan
  • 554
  • 5
  • 20