help - simple c function if condition

Zaki Ahmed

Well Known Member
I have customized a c function that isn't working.

I have taken last 2 characters of a string, and if the value is not "20", i need to pass a EOL character, otherwise not.

It always goes to ELSE logic and doesn't hit the logic where it gets equal to value of "20". See attachment as well. Not sure what I am doing wrong.

Here's my function.

jdeStrncpy((JCHAR *)szLast2CharString, (JCHAR *)szWorkString+998,2);
szLast2CharString[2] = _J('\0');
if (szLast2CharString == (const JCHAR *) _J("20"))
{
lWrittenByte = jdeFprintfConvert(lpBhvrCom, fOutFile, _J("%ls"), szWorkString);
}
else
{
lWrittenByte = jdeFprintfConvert(lpBhvrCom, fOutFile, _J("%ls\n"), szWorkString);


JDE 9.0
Tools Release 8.98
 

Attachments

  • C function screenshot.jpg
    C function screenshot.jpg
    29.8 KB · Views: 10
You need to compare strings using jdestrcmp.

if (jdestrcmp(szLast2CharString, _J("20")) == 0)
{
/* Matches */
}
else
{
/* doesn't match */
}

Craig
 
Back
Top