Re: C program for QDFRTVFD API

Frank Kolmann <[email protected]>
Newsgroups gmane.comp.lang.as400.c
Message-ID <CAB-SQvjG4D5RdYNx=KiQ1VgPYPDm8wuYMx10ABoQT3x7wth4xQ@mail.gmail.com>
Hi Jevgeni

Thank you for the correction.  I have modified my code.
I should have known this but just shows I need more practice.
I believe I have learnt now there is nothing magic about C functions.
If the string variable is not null terminated you need to handle lengths
explicitly.
Seems that strcmp and sizeof need null terminated strings to work.
Also the original code mostly worked Ok, because the row and col are 1 byte
values and I
did not have more than one field in the same place.

Regards
Frank

>date: Tue, 23 Sep 2014 12:13:54 +0300
>from: Jevgeni Astanovski <jevgeniast@****.com>
>This part of code is invalid, I think:
>-snip
>If understand correctly your intention, you wanted to compare 2 record
>names, 2 field names, row and column of the 2 fields.
>But in fact I think that you only compare the first character of the 2
>records and the first character of the field names as
>sizeof(*p_iRecord) equals to 1.
>I would write it so:
>   if (!memcmp(Functn , "#NEXT"  , 5)  &&
>       !memcmp(p_iRecord, Odata->RecordName, 10) &&
>       !memcmp(p_iField, Odata->FldNam, 10 ) &&
>       (*p_iRow == *Odata->ROW) &&
>       (*p_iCol == *Odata->COL))
>              *GotIt = 1;
-- 
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list
To post a message email: C400-L-Zwy7GipZuJhWk0Htik3J/[email protected]
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request-Zwy7GipZuJhWk0Htik3J/[email protected]
Before posting, please take a moment to review the archives
at http://archive.midrange.com/c400-l.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.