Operating System - HP-UX
1752796 Members
5835 Online
108789 Solutions
New Discussion юеВ

Re: strcmp not working at certain portions of same program

 
tl1st3n
Occasional Contributor

strcmp not working at certain portions of same program

Hi all,

These days I come across a strange problem wherein strcmp doesn't work at certain parts of my C program. I explicitly need to compare each character of the string in the array using == with the individual alphabet. e.g. actn[0]=='R'

Has any of you come across this issue before?

string.h has been included as one of the header files.

OS: HP-UX B.11.00
CC compiler

Any input is appreciated
4 REPLIES 4
Steven Schweda
Honored Contributor

Re: strcmp not working at certain portions of same program

> Any input is appreciated

You first. Actual code might reveal more
than a vague (and confusing) description.

> [...] e.g. actn[0]=='R'

What does that have to do with strcmp()?

> [...] strcmp doesn't work [...]

Much more likely: Your code is bad.
Dennis Handly
Acclaimed Contributor

Re: strcmp not working at certain portions of same program

>OS: HP-UX B.11.00

You are out of luck, this HP-UX version isn't supported nor is the compiler. What compiler version are you using?
Laurent Menase
Honored Contributor

Re: strcmp not working at certain portions of same program

I think you can consider that strcmp() is working and that the problem is elsewhere, and input strings are not the one you expect.
Maybe due to a memory corruption.
changing the code move can change the corruption footprint.
Or ending 0 is missing.
or there is a 0 at the middle of the string - which would mean it stops the comp at the first 0 encountered.




Dennis Handly
Acclaimed Contributor

Re: strcmp not working at certain portions of same program

You could set a breakpoint in strcmp and then print out the arguments in gdb:
b * strcmp
x /s $r26
x /s $r25